Skip to content

Commit

Permalink
feat: add tutor integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed Jun 7, 2024
1 parent f7c3ed1 commit 26bc17f
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Tutor Integration Tests
on: [pull_request]

jobs:
integration-test:
name: Tutor Integration Test
runs-on: ubuntu-latest
strategy:
matrix:
tutor_version: ["<17.0.0", "<18.0.0"]
steps:
- uses: actions/checkout@v4
with:
path: eox-theming
- uses: eduNEXT/integration-test-in-tutor@main
with:
tutor_version: ${{ matrix.tutor_version }}
app_name: "eox-theming"
shell_file_to_run: "eox_theming/tests/tutor/integration.sh"
13 changes: 13 additions & 0 deletions eox_theming/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

from __future__ import unicode_literals

import codecs
import os

import yaml

from .common import * # pylint: disable=wildcard-import


Expand Down Expand Up @@ -62,3 +67,11 @@ def plugin_settings(settings): # pylint: disable=function-redefined
settings.STATICFILES_FINDERS = [
x for x in settings.STATICFILES_FINDERS if 'EoxThemeFilesFinder' not in x
]

# 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)
# print(f'\n\nEnv Tokens: {env_tokens}\n\n')
settings.DATABASES = env_tokens['DATABASES']
Empty file.
16 changes: 16 additions & 0 deletions eox_theming/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


@pytest.fixture(scope="session")
def django_db_setup():
"""
Makes the tests reuse the existing database
"""
11 changes: 11 additions & 0 deletions eox_theming/tests/tutor/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# This script installs the package in the edxapp environment, installs test requirements from Open edX and runs the tests using the Tutor settings.
echo "Install package"
pip install -e /openedx/eox-theming

echo "Install test-requirements"
make test-requirements

echo "Run tests"
pytest -s --ds=lms.envs.tutor.test /openedx/eox-theming/eox_theming/tests/tutor
24 changes: 24 additions & 0 deletions eox_theming/tests/tutor/integration_test_tutor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Test integration file.
"""
from django.test import TestCase


class TutorIntegrationTestCase(TestCase):
"""
Tests integration with Open edX
"""

# 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
"""
# isort: off
import eox_theming.edxapp_wrapper.backends.j_configuration_helpers
import eox_theming.edxapp_wrapper.backends.j_finders
import eox_theming.edxapp_wrapper.backends.j_loaders
import eox_theming.edxapp_wrapper.backends.j_models
import eox_theming.edxapp_wrapper.backends.j_theming_helpers
import eox_theming.edxapp_wrapper.backends.l_mako
import eox_theming.edxapp_wrapper.backends.l_storage
7 changes: 7 additions & 0 deletions eox_theming/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 @@ coverage
mako
path-py
testfixtures
pyyaml
19 changes: 11 additions & 8 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ astroid==2.13.5
# via
# -r requirements/test.in
# pylint
coverage==7.4.0
coverage==7.5.3
# via -r requirements/test.in
dill==0.3.7
dill==0.3.8
# via pylint
django==4.2.9
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
Expand All @@ -28,19 +29,19 @@ isort==5.13.2
# via pylint
lazy-object-proxy==1.10.0
# via astroid
mako==1.3.0
mako==1.3.5
# via -r requirements/test.in
markupsafe==2.1.3
markupsafe==2.1.5
# via mako
mccabe==0.7.0
# via pylint
mock==5.1.0
# via -r requirements/test.in
path==16.9.0
path==16.14.0
# via path-py
path-py==12.5.0
# via -r requirements/test.in
platformdirs==4.1.0
platformdirs==4.2.2
# via pylint
pycodestyle==2.8.0
# via
Expand All @@ -50,17 +51,19 @@ pylint==2.15.10
# via
# -c requirements/constraints.txt
# -r requirements/test.in
pyyaml==6.0.1
# via -r requirements/test.in
six==1.16.0
# via -r requirements/base.txt
sqlparse==0.4.4
# via
# -r requirements/base.txt
# django
testfixtures==7.2.2
testfixtures==8.2.0
# via -r requirements/test.in
tomli==2.0.1
# via pylint
tomlkit==0.12.3
tomlkit==0.12.5
# via pylint
typing-extensions==4.9.0
# via
Expand Down

0 comments on commit 26bc17f

Please sign in to comment.