diff --git a/eox_tenant/settings/test.py b/eox_tenant/settings/test.py index 30e05fa5..c984e892 100644 --- a/eox_tenant/settings/test.py +++ b/eox_tenant/settings/test.py @@ -3,10 +3,10 @@ """ from __future__ import absolute_import, unicode_literals -import os import codecs -import yaml +import os +import yaml from .common import * # pylint: disable=wildcard-import,unused-wildcard-import @@ -15,13 +15,6 @@ class SettingsClass: """ dummy settings class """ OAUTH2_PROVIDER = {} -def get_env_setting(setting): - """ Get the environment setting or return exception """ - try: - return os.environ[setting] - except KeyError: - error_msg = "Set the %s env variable" % setting - raise ImproperlyConfigured(error_msg) # lint-amnesty, pylint: disable=raise-missing-from ALLOWED_HOSTS = ['*'] SETTINGS = SettingsClass() @@ -104,6 +97,6 @@ def plugin_settings(settings): # pylint: disable=function-redefined ) # setup the databases used in the tutor local environment - with codecs.open(get_env_setting('LMS_CFG'), encoding='utf-8') as f: - ENV_TOKENS = yaml.safe_load(f) - settings.DATABASES = ENV_TOKENS['DATABASES'] + with codecs.open(os.environ['LMS_CFG'], encoding='utf-8') as f: + env_tokens = yaml.safe_load(f) + settings.DATABASES = env_tokens['DATABASES'] diff --git a/eox_tenant/tenant_aware_functions/enrollments.py b/eox_tenant/tenant_aware_functions/enrollments.py index b7e1f794..06a66aa9 100644 --- a/eox_tenant/tenant_aware_functions/enrollments.py +++ b/eox_tenant/tenant_aware_functions/enrollments.py @@ -18,8 +18,7 @@ def filter_enrollments(enrollments): # If test setting is true, returns the same enrollments, # or if we do not have a microsite context, there is nothing we can do. if test_skip or not theming_helpers.is_request_in_themed_site(): - for enrollment in enrollments: - yield enrollment + yield from enrollments return configuration_helpers = get_configuration_helpers() diff --git a/eox_tenant/test/tutor/conftest.py b/eox_tenant/test/tutor/conftest.py index c0c97b61..cf72ca93 100644 --- a/eox_tenant/test/tutor/conftest.py +++ b/eox_tenant/test/tutor/conftest.py @@ -1,4 +1,12 @@ -import pytest +""" +The conftest module sets up the database connection for pytest-django. + +The integration tests will reuse the database from tutor local so a noop +django_db_setup is required. +See: https://pytest-django.readthedocs.io/en/latest/database.html +""" + +import pytest # pylint: disable=import-error @pytest.fixture(scope='session') @@ -6,4 +14,3 @@ def django_db_setup(): """ Makes the tests reuse the existing database """ - pass diff --git a/eox_tenant/test/tutor/integration_test_tutor.py b/eox_tenant/test/tutor/integration_test_tutor.py index c9ffe89d..1160059a 100644 --- a/eox_tenant/test/tutor/integration_test_tutor.py +++ b/eox_tenant/test/tutor/integration_test_tutor.py @@ -2,8 +2,6 @@ Test views file. """ from django.test import TestCase -from django.urls import reverse -from django.conf import settings class TutorIntegrationTestCase(TestCase): @@ -17,17 +15,21 @@ def test_runs_code(self): """ assert True + # pylint: disable=import-outside-toplevel,unused-import def test_current_settings_code_imports(self): """ Running this imports means that our backends import the right signature """ import eox_tenant.edxapp_wrapper.backends.oauth_dispatch_j_v1 import eox_tenant.edxapp_wrapper.backends.branding_api_l_v1 - # import eox_tenant.edxapp_wrapper.backends.certificates_module_i_v1 # fixme + # fixme: needs to be properly removed if unused at the latest version # pylint: disable=fixme + # import eox_tenant.edxapp_wrapper.backends.certificates_module_i_v1 import eox_tenant.edxapp_wrapper.backends.site_configuration_module_i_v1 import eox_tenant.edxapp_wrapper.backends.theming_helpers_h_v1 - # import eox_tenant.edxapp_wrapper.backends.edx_auth_i_v1 # fixme + # fixme: needs to be properly removed if unused at the latest version # pylint: disable=fixme + # import eox_tenant.edxapp_wrapper.backends.edx_auth_i_v1 import eox_tenant.edxapp_wrapper.backends.users_l_v1 import eox_tenant.edxapp_wrapper.backends.bearer_authentication_l_v1 import eox_tenant.edxapp_wrapper.backends.edxmako_l_v1 + # fixme: needs to be properly removed if unused at the latest version # pylint: disable=fixme # import eox_tenant.edxapp_wrapper.backends.util_h_v1 # fixme