diff --git a/eox_core/settings/test.py b/eox_core/settings/test.py index 0964aa86c..fee4a894a 100644 --- a/eox_core/settings/test.py +++ b/eox_core/settings/test.py @@ -4,6 +4,11 @@ from __future__ import absolute_import, unicode_literals +import codecs +import os + +import yaml + from .common import * # pylint: disable=wildcard-import, unused-wildcard-import @@ -35,6 +40,13 @@ def plugin_settings(settings): # pylint: disable=function-redefined settings.EOX_CORE_THIRD_PARTY_AUTH_BACKEND = 'eox_core.edxapp_wrapper.backends.third_party_auth_l_v1' settings.EOX_CORE_LANG_PREF_BACKEND = 'eox_core.edxapp_wrapper.backends.lang_pref_middleware_p_v1_test' + # setup the databases used in the tutor local environment + lms_cfg = os.environ.get('LMS_CFG') + if lms_cfg: + with codecs.open(lms_cfg, encoding='utf-8') as file: + env_tokens = yaml.safe_load(file) + settings.DATABASES = env_tokens['DATABASES'] + SETTINGS = SettingsClass() plugin_settings(SETTINGS) diff --git a/eox_core/tests/tutor/__init__.py b/eox_core/tests/tutor/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/eox_core/tests/tutor/conftest.py b/eox_core/tests/tutor/conftest.py new file mode 100644 index 000000000..cf72ca93b --- /dev/null +++ b/eox_core/tests/tutor/conftest.py @@ -0,0 +1,16 @@ +""" +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') +def django_db_setup(): + """ + Makes the tests reuse the existing database + """ diff --git a/eox_core/tests/tutor/integration_test_tutor.py b/eox_core/tests/tutor/integration_test_tutor.py new file mode 100644 index 000000000..ba4db9a8a --- /dev/null +++ b/eox_core/tests/tutor/integration_test_tutor.py @@ -0,0 +1,26 @@ +""" +Test integration file. +""" +from django.test import TestCase + + +class TutorIntegrationTestCase(TestCase): + """ + Tests integration with openedx + """ + + # 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_core.edxapp_wrapper.backends.bearer_authentication_j_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.certificates_m_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.comments_service_users_j_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.configuration_helpers_h_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.coursekey_m_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.edxfuture_o_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.grades_h_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.pre_enrollment_l_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.storages_i_v1 # isort:skip + import eox_core.edxapp_wrapper.backends.third_party_auth_l_v1 # isort:skip diff --git a/eox_core/tests/tutor/pytest.ini b/eox_core/tests/tutor/pytest.ini new file mode 100644 index 000000000..f3b746245 --- /dev/null +++ b/eox_core/tests/tutor/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +python_files = integration_test_*.py +filterwarnings = + default + # We ignore every warning while we actually get the testing infrastructure + # running for different version of tutor in gh actions + ignore: diff --git a/requirements/test.in b/requirements/test.in index d9cf47261..0d6433ae2 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -10,3 +10,4 @@ pytest pytest-django testfixtures django-countries +pyyaml diff --git a/requirements/test.txt b/requirements/test.txt index 0999cbe1e..08366eccb 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -314,6 +314,8 @@ pymongo==3.13.0 # -r requirements/base.txt # edx-opaque-keys # event-tracking +pyyaml==6.0.1 + # via -r requirements/test.in pynacl==1.5.0 # via # -r requirements/base.txt