From 3be143bfcd8c52b4d68d699cdcd1764e0d11d480 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Tue, 24 Sep 2019 17:59:17 +0300 Subject: [PATCH] Fixed test order --- .circleci/config.yml | 10 +-- .../api/test_email_notifications.py | 74 +++++++++---------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ea340aa94e..26fe4eb5d69 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,7 @@ jobs: CKAN_POSTGRES_PWD: pass PGPASSWORD: ckan NODE_TESTS_CONTAINER: 2 - PYTEST_COMMON_OPTIONS: -v --ckan-ini=test-core-circle-ci.ini --cov=ckan --cov=ckanext --junitxml=/root/junit/junit.xml + PYTEST_COMMON_OPTIONS: -v --ckan-ini=test-core-circle-ci.ini --cov=ckan --cov=ckanext --junitxml=/root/junit/junit.xml --test-group-count 4 --test-group-random-seed=12345 - image: postgres:10 environment: POSTGRES_USER: ckan @@ -65,13 +65,13 @@ jobs: - run: | mkdir -p ~/junit case $CIRCLE_NODE_INDEX in - 0) python -m pytest $PYTEST_COMMON_OPTIONS --test-group-count 4 --test-group 1 + 0) python -m pytest $PYTEST_COMMON_OPTIONS --test-group 1 ;; - 1) python -m pytest $PYTEST_COMMON_OPTIONS --test-group-count 4 --test-group 2 + 1) python -m pytest $PYTEST_COMMON_OPTIONS --test-group 2 ;; - 2) python -m pytest $PYTEST_COMMON_OPTIONS --test-group-count 4 --test-group 3 + 2) python -m pytest $PYTEST_COMMON_OPTIONS --test-group 3 ;; - 3) python -m pytest $PYTEST_COMMON_OPTIONS --test-group-count 4 --test-group 4 + 3) python -m pytest $PYTEST_COMMON_OPTIONS --test-group 4 ;; esac - store_test_results: diff --git a/ckan/tests/legacy/functional/api/test_email_notifications.py b/ckan/tests/legacy/functional/api/test_email_notifications.py index 26b9147472c..e3a29e69b5f 100644 --- a/ckan/tests/legacy/functional/api/test_email_notifications.py +++ b/ckan/tests/legacy/functional/api/test_email_notifications.py @@ -17,17 +17,29 @@ def setup_class(cls): tests.CreateTestData.create() cls.app = helpers._get_test_app() joeadmin = model.User.get('joeadmin') - cls.joeadmin = {'id': joeadmin.id, - 'apikey': joeadmin.apikey, - } + cls.joeadmin = { + 'id': joeadmin.id, + 'apikey': joeadmin.apikey + } testsysadmin = model.User.get('testsysadmin') - cls.testsysadmin = {'id': testsysadmin.id, - 'apikey': testsysadmin.apikey, - } + cls.testsysadmin = { + 'id': testsysadmin.id, + 'apikey': testsysadmin.apikey + } annafan = model.User.get('annafan') - cls.annafan = {'id': annafan.id, - 'apikey': annafan.apikey, - } + cls.annafan = { + 'id': annafan.id, + 'apikey': annafan.apikey + } + + # Register a new user. + cls.sara = tests.call_action_api( + cls.app, 'user_create', + apikey=cls.testsysadmin['apikey'], name='sara', + email='sara@sararollins.com', password='TestPassword1', + fullname='Sara Rollins', + activity_streams_email_notifications=True + ) @classmethod def teardown_class(cls): @@ -64,16 +76,6 @@ def test_01_no_email_notifications_after_registration(self): apikey=self.testsysadmin['apikey']) self.clear_smtp_messages() - # Register a new user. - sara = tests.call_action_api(self.app, 'user_create', - apikey=self.testsysadmin['apikey'], name='sara', - email='sara@sararollins.com', password='TestPassword1', - fullname='Sara Rollins', - activity_streams_email_notifications=True) - - # Save the user for later tests to use. - TestEmailNotifications.sara = sara - # No notification emails should be sent to anyone at this point. tests.call_action_api(self.app, 'send_email_notifications', apikey=self.testsysadmin['apikey']) @@ -188,13 +190,22 @@ def setup_class(cls): tests.CreateTestData.create() cls.app = helpers._get_test_app() joeadmin = model.User.get('joeadmin') - cls.joeadmin = {'id': joeadmin.id, - 'apikey': joeadmin.apikey, - } + cls.joeadmin = { + 'id': joeadmin.id, + 'apikey': joeadmin.apikey + } + testsysadmin = model.User.get('testsysadmin') - cls.testsysadmin = {'id': testsysadmin.id, - 'apikey': testsysadmin.apikey, - } + cls.testsysadmin = { + 'id': testsysadmin.id, + 'apikey': testsysadmin.apikey + } + cls.sara = tests.call_action_api( + cls.app, 'user_create', + apikey=cls.testsysadmin['apikey'], name='sara', + email='sara@sararollins.com', password='TestPassword1', + fullname='Sara Rollins' + ) @classmethod def teardown_class(self): @@ -203,18 +214,7 @@ def teardown_class(self): def test_00_email_notifications_disabled_by_default(self): '''Email notifications should be disabled for new users.''' - - # Register a new user. - sara = tests.call_action_api(self.app, 'user_create', - apikey=self.testsysadmin['apikey'], name='sara', - email='sara@sararollins.com', password='TestPassword1', - fullname='Sara Rollins') - - # Save the user for later tests to use. - TestEmailNotificationsUserPreference.sara = sara - - # Email notifications should be disabled for the new user. - assert sara['activity_streams_email_notifications'] is False + assert self.sara['activity_streams_email_notifications'] is False assert (tests.call_action_api(self.app, 'user_show', apikey=self.sara['apikey'], id='sara')[ 'activity_streams_email_notifications'] is False)