Skip to content

Commit

Permalink
feat: add integration test file (#267)
Browse files Browse the repository at this point in the history
* feat: add integration test file

* feat: add integration test file

* fix: plugin_settings function

* fix: plugin_settings function

* fix: plugin_settings function

* fix: plugin_settings function

* fix: plugin_settings function

* fix: plugin_settings function
  • Loading branch information
luisfelipec95 authored May 24, 2024
1 parent 51b73d2 commit beddb10
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 0 deletions.
12 changes: 12 additions & 0 deletions eox_core/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
Empty file.
16 changes: 16 additions & 0 deletions eox_core/tests/tutor/conftest.py
Original file line number Diff line number Diff line change
@@ -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
"""
26 changes: 26 additions & 0 deletions eox_core/tests/tutor/integration_test_tutor.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions eox_core/tests/tutor/pytest.ini
Original file line number Diff line number Diff line change
@@ -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:
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pytest
pytest-django
testfixtures
django-countries
pyyaml
2 changes: 2 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit beddb10

Please sign in to comment.