From 95f0ff35639319fca7ca7433070a4a1226d4ef62 Mon Sep 17 00:00:00 2001 From: Simon Pirkelmann Date: Mon, 31 Jan 2022 22:59:44 +0100 Subject: [PATCH] added test for backing up user datastore --- tests/conftest.py | 3 +++ tests/test_webinterface.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 411fa2c..5ba7c39 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,11 @@ import pytest +import os from selenium.webdriver import Chrome from imaginaerraum_door_admin import create_app +os.environ['APPLICATION_SETTINGS'] = os.getcwd() + '/debug_app_config.py' + @pytest.fixture(scope='session') def app(): diff --git a/tests/test_webinterface.py b/tests/test_webinterface.py index f0c31d2..97af12e 100644 --- a/tests/test_webinterface.py +++ b/tests/test_webinterface.py @@ -154,6 +154,18 @@ def temp_admin(client_authenticated): 'password': password} +def test_backup_users(client_authenticated, temp_user): + # test with invalid token + response = client_authenticated.get("/backup_user_datastore", + follow_redirects=True) + user_data = json.loads(response.data) + users = [d['username'] for d in user_data] + emails = [d['email'] for d in user_data] + + assert temp_user['username'] in users + assert temp_user['email'] in emails + + def test_create_admin(client_authenticated): password = create_user(client_authenticated, 'bilbo', 'bilbo@shire.me')