From 4e5954746d0771d0beafca9ba1c373567f0371ff Mon Sep 17 00:00:00 2001 From: magajh Date: Mon, 14 Oct 2024 14:50:17 -0400 Subject: [PATCH 01/19] chore: add pytest to requirements --- requirements/base.txt | 2 +- requirements/pip-tools.txt | 16 +++++++--------- requirements/test.in | 2 ++ requirements/test.txt | 34 +++++++++++++++++++++++++--------- requirements/tox.txt | 18 ++++++++++-------- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index f2f0f28..4d02ac7 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -10,7 +10,7 @@ backports-zoneinfo==0.2.1 ; python_version < "3.9" # via # -c requirements/constraints.txt # django -django==4.2.14 +django==4.2.16 # via # -c https://raw.githubusercontent.com/openedx/edx-lint/master/edx_lint/files/common_constraints.txt # -r requirements/base.in diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index 69e02c9..c939293 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -4,29 +4,27 @@ # # make upgrade # -build==1.2.1 +build==1.2.2.post1 # via pip-tools click==8.1.7 # via pip-tools -importlib-metadata==6.11.0 - # via - # -c https://raw.githubusercontent.com/openedx/edx-lint/master/edx_lint/files/common_constraints.txt - # build +importlib-metadata==8.5.0 + # via build packaging==24.1 # via build pip-tools==7.4.1 # via -r requirements/pip-tools.in -pyproject-hooks==1.1.0 +pyproject-hooks==1.2.0 # via # build # pip-tools -tomli==2.0.1 +tomli==2.0.2 # via # build # pip-tools -wheel==0.43.0 +wheel==0.44.0 # via pip-tools -zipp==3.19.2 +zipp==3.20.2 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/test.in b/requirements/test.in index 8726fc5..d95462f 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -4,6 +4,8 @@ Django mock pylint +pytest +pytest-django astroid pycodestyle coverage diff --git a/requirements/test.txt b/requirements/test.txt index f1e7ede..1e6a8e0 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -17,9 +17,9 @@ backports-zoneinfo==0.2.1 ; python_version < "3.9" # -c requirements/constraints.txt # -r requirements/base.txt # django -coverage==7.6.0 +coverage==7.6.1 # via -r requirements/test.in -dill==0.3.8 +dill==0.3.9 # via pylint # via # -c https://raw.githubusercontent.com/openedx/edx-lint/master/edx_lint/files/common_constraints.txt @@ -27,6 +27,10 @@ dill==0.3.8 # -r requirements/test.in eox-tenant==11.7.0 # via -r requirements/base.txt +exceptiongroup==1.2.2 + # via pytest +iniconfig==2.0.0 + # via pytest isort==5.13.2 # via pylint mako==1.3.5 @@ -37,17 +41,27 @@ mccabe==0.7.0 # via pylint mock==5.1.0 # via -r requirements/test.in +packaging==24.1 + # via pytest path==17.0.0 # via path-py path-py==12.5.0 # via -r requirements/test.in -platformdirs==4.2.2 +platformdirs==4.3.6 # via pylint -pycodestyle==2.12.0 +pluggy==1.5.0 + # via pytest +pycodestyle==2.12.1 # via -r requirements/test.in -pylint==3.2.6 +pylint==3.2.7 # via -r requirements/test.in -pyyaml==6.0.1 +pytest==8.3.3 + # via + # -r requirements/test.in + # pytest-django +pytest-django==4.9.0 + # via -r requirements/test.in +pyyaml==6.0.2 # via -r requirements/test.in six==1.16.0 # via -r requirements/base.txt @@ -57,9 +71,11 @@ sqlparse==0.5.1 # django testfixtures==8.3.0 # via -r requirements/test.in -tomli==2.0.1 - # via pylint -tomlkit==0.13.0 +tomli==2.0.2 + # via + # pylint + # pytest +tomlkit==0.13.2 # via pylint typing-extensions==4.12.2 # via diff --git a/requirements/tox.txt b/requirements/tox.txt index 67e374e..2836025 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -4,15 +4,15 @@ # # make upgrade # -cachetools==5.4.0 +cachetools==5.5.0 # via tox chardet==5.2.0 # via tox colorama==0.4.6 # via tox -distlib==0.3.8 +distlib==0.3.9 # via virtualenv -filelock==3.15.4 +filelock==3.16.1 # via # tox # virtualenv @@ -20,19 +20,21 @@ packaging==24.1 # via # pyproject-api # tox -platformdirs==4.2.2 +platformdirs==4.3.6 # via # tox # virtualenv pluggy==1.5.0 # via tox -pyproject-api==1.7.1 +pyproject-api==1.8.0 # via tox -tomli==2.0.1 +tomli==2.0.2 # via # pyproject-api # tox -tox==4.16.0 +tox==4.21.2 # via -r requirements/tox.in -virtualenv==20.26.3 +typing-extensions==4.12.2 + # via tox +virtualenv==20.26.6 # via tox From e9942de817d06edcdeab4830aaffac4d57298581 Mon Sep 17 00:00:00 2001 From: magajh Date: Mon, 14 Oct 2024 14:52:15 -0400 Subject: [PATCH 02/19] chore(ci): execute tests with pytest and update integration tests workflow --- .github/workflows/integration-test.yml | 15 +++++++-------- Makefile | 3 ++- eox_theming/edxapp_wrapper/tests/__init__.py | 0 .../tests/integration/__init__.py | 0 .../tests/integration/test_backends.py | 17 +++++++++++++++++ scripts/execute_integration_tests.sh | 10 ++++++++++ setup.cfg | 3 +++ 7 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 eox_theming/edxapp_wrapper/tests/__init__.py create mode 100644 eox_theming/edxapp_wrapper/tests/integration/__init__.py create mode 100644 eox_theming/edxapp_wrapper/tests/integration/test_backends.py create mode 100644 scripts/execute_integration_tests.sh diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index eeb1629..8ca3fec 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -3,17 +3,16 @@ on: [pull_request] jobs: integration-test: - name: Tutor Integration Test + name: Tutor Integration Tests runs-on: ubuntu-latest strategy: matrix: - tutor_version: ["<17.0.0", "<18.0.0", "<19.0.0"] + tutor_version: ['<18.0.0', '<19.0.0', 'nightly'] steps: - - uses: actions/checkout@v4 - with: - path: eox-theming - - uses: eduNEXT/integration-test-in-tutor@main + - name: Run Integration Tests + uses: eduNEXT/integration-test-in-tutor@mjh/make-extra-reqs-step-optional with: tutor_version: ${{ matrix.tutor_version }} - app_name: "eox-theming" - shell_file_to_run: "eox_theming/tests/tutor/integration.sh" + app_name: 'eox-theming' + shell_file_to_run: 'scripts/execute_integration_tests.sh' + openedx_imports_test_file_path: 'eox_theming/edxapp_wrapper/tests/integration/test_backends.py' diff --git a/Makefile b/Makefile index f03224e..2dc1fcd 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ requirements: ## install environment requirements install-dev-dependencies: ## install tox pip install -r requirements/tox.txt + pip install -r requirements/test.txt upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in @@ -48,7 +49,7 @@ quality: clean ## check coding style with pycodestyle and pylint test-python: clean ## Run test suite. $(TOX) pip install -r requirements/test.txt --exists-action w - $(TOX) coverage run --source ./eox_theming manage.py test + $(TOX) coverage run --source="." -m pytest ./eox_theming --ignore-glob='**/integration/*' $(TOX) coverage report -m --fail-under=74 run-tests: test-python quality diff --git a/eox_theming/edxapp_wrapper/tests/__init__.py b/eox_theming/edxapp_wrapper/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eox_theming/edxapp_wrapper/tests/integration/__init__.py b/eox_theming/edxapp_wrapper/tests/integration/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eox_theming/edxapp_wrapper/tests/integration/test_backends.py b/eox_theming/edxapp_wrapper/tests/integration/test_backends.py new file mode 100644 index 0000000..a42b049 --- /dev/null +++ b/eox_theming/edxapp_wrapper/tests/integration/test_backends.py @@ -0,0 +1,17 @@ +""" +This module tests the backends of the edxapp_wrapper +""" + + +# pylint: disable=import-outside-toplevel, unused-import +def test_current_settings_code_imports(): + """ + Running this imports means that our backends import the right signature + """ + 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 diff --git a/scripts/execute_integration_tests.sh b/scripts/execute_integration_tests.sh new file mode 100644 index 0000000..e2f1a3b --- /dev/null +++ b/scripts/execute_integration_tests.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Install requirements" +make install-dev-dependencies + +echo "Run tests" +# Since we don't have any integration tests at the moment, +# we allow pytest to pass without running any tests. +pytest -rPf --allow-no-tests + diff --git a/setup.cfg b/setup.cfg index a00ee50..715a0cc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,9 @@ current_version = 7.2.0 commit = False tag = False +[tool:pytest] +DJANGO_SETTINGS_MODULE = eox_theming.settings.test + [pylint] ignore = migrations,CVS max-line-length = 120 From b9bba774597b74e18fb718e3e954b50264003ec3 Mon Sep 17 00:00:00 2001 From: magajh Date: Mon, 14 Oct 2024 15:09:51 -0400 Subject: [PATCH 03/19] chore: remove tutor test folder --- eox_theming/tests/tutor/__init__.py | 0 eox_theming/tests/tutor/conftest.py | 16 ------------- eox_theming/tests/tutor/integration.sh | 11 --------- .../tests/tutor/integration_test_tutor.py | 24 ------------------- eox_theming/tests/tutor/pytest.ini | 7 ------ 5 files changed, 58 deletions(-) delete mode 100644 eox_theming/tests/tutor/__init__.py delete mode 100644 eox_theming/tests/tutor/conftest.py delete mode 100644 eox_theming/tests/tutor/integration.sh delete mode 100644 eox_theming/tests/tutor/integration_test_tutor.py delete mode 100644 eox_theming/tests/tutor/pytest.ini diff --git a/eox_theming/tests/tutor/__init__.py b/eox_theming/tests/tutor/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/eox_theming/tests/tutor/conftest.py b/eox_theming/tests/tutor/conftest.py deleted file mode 100644 index 00e8274..0000000 --- a/eox_theming/tests/tutor/conftest.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -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_theming/tests/tutor/integration.sh b/eox_theming/tests/tutor/integration.sh deleted file mode 100644 index 1606802..0000000 --- a/eox_theming/tests/tutor/integration.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/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 diff --git a/eox_theming/tests/tutor/integration_test_tutor.py b/eox_theming/tests/tutor/integration_test_tutor.py deleted file mode 100644 index 86b63d1..0000000 --- a/eox_theming/tests/tutor/integration_test_tutor.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -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 diff --git a/eox_theming/tests/tutor/pytest.ini b/eox_theming/tests/tutor/pytest.ini deleted file mode 100644 index f3b7462..0000000 --- a/eox_theming/tests/tutor/pytest.ini +++ /dev/null @@ -1,7 +0,0 @@ -[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: From 5d96aa8e9dc531612631823a19d884b267c2e7b6 Mon Sep 17 00:00:00 2001 From: magajh Date: Mon, 14 Oct 2024 15:10:36 -0400 Subject: [PATCH 04/19] fix: leave script to execute integration tests empty --- scripts/execute_integration_tests.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/execute_integration_tests.sh b/scripts/execute_integration_tests.sh index e2f1a3b..bee0f74 100644 --- a/scripts/execute_integration_tests.sh +++ b/scripts/execute_integration_tests.sh @@ -1,10 +1,4 @@ #!/bin/bash -echo "Install requirements" -make install-dev-dependencies - -echo "Run tests" -# Since we don't have any integration tests at the moment, -# we allow pytest to pass without running any tests. -pytest -rPf --allow-no-tests - +# As we currently don't have any integration tests, +# this script is intentionally left empty. From cc5ab102bc517dcc676327a5406da6b01ac7bcd3 Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 06:55:02 -0400 Subject: [PATCH 05/19] refactor: create target and add eox-info test case for integration tests --- Makefile | 4 ++ eox_theming/settings/test.py | 8 ++++ .../tests/management/integration/__init__.py | 0 .../management/integration/test_views.py | 38 +++++++++++++++++++ scripts/execute_integration_tests.sh | 3 +- 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 eox_theming/tests/management/integration/__init__.py create mode 100644 eox_theming/tests/management/integration/test_views.py diff --git a/Makefile b/Makefile index 2dc1fcd..bb782b6 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,10 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy sed '/^[dD]jango==/d;' requirements/test.txt > requirements/test.tmp mv requirements/test.tmp requirements/test.txt +run-integration-tests: + install-dev-dependencies + pytest -rPf ./eox_theming/tests/management/integration + quality: clean ## check coding style with pycodestyle and pylint $(TOX) pycodestyle ./eox_theming $(TOX) pylint ./eox_theming --rcfile=./setup.cfg diff --git a/eox_theming/settings/test.py b/eox_theming/settings/test.py index fd95b76..fe77634 100644 --- a/eox_theming/settings/test.py +++ b/eox_theming/settings/test.py @@ -74,3 +74,11 @@ def plugin_settings(settings): # pylint: disable=function-redefined with codecs.open(lms_cfg, encoding='utf-8') as file: env_tokens = yaml.safe_load(file) settings.DATABASES = env_tokens['DATABASES'] + + +# Integration tests settings +INTEGRATION_TEST_SETTINGS = { + # Retrieved from the Tutor environment where the integration tests run + "EOX_THEMING_BASE_URL": f"http://{os.environ.get('LMS_HOST', 'local.edly.io')}/eox-tenant", + "API_TIMEOUT": 5, +} diff --git a/eox_theming/tests/management/integration/__init__.py b/eox_theming/tests/management/integration/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eox_theming/tests/management/integration/test_views.py b/eox_theming/tests/management/integration/test_views.py new file mode 100644 index 0000000..460a1c7 --- /dev/null +++ b/eox_theming/tests/management/integration/test_views.py @@ -0,0 +1,38 @@ +""" +Integration test for EOX Info view. +""" +import requests +from django.conf import settings as ds +from django.test import TestCase +from django.urls import reverse +from rest_framework import status + +settings = ds.INTEGRATION_TEST_SETTINGS + + +class TestInfoView(TestCase): + """ + Integration test suite for the info view. + """ + + def setUp(self) -> None: + """ + Set up the test suite. + """ + self.url = f"{settings['EOX_THEMING_BASE_URL']}{reverse('eox-info')}" + super().setUp() + + def test_info_view_success(self) -> None: + """Test the info view. + + Expected result: + - The status code is 200. + - The response contains the version, name and git commit hash. + """ + response = requests.get(self.url, timeout=settings["API_TIMEOUT"]) + + response_data = response.json() + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertIn("version", response_data) + self.assertIn("name", response_data) + self.assertIn("git", response_data) diff --git a/scripts/execute_integration_tests.sh b/scripts/execute_integration_tests.sh index bee0f74..066dfac 100644 --- a/scripts/execute_integration_tests.sh +++ b/scripts/execute_integration_tests.sh @@ -1,4 +1,3 @@ #!/bin/bash -# As we currently don't have any integration tests, -# this script is intentionally left empty. +run-integration-tests From 990da8f39ce83f82eeeb306f95a638b0fdb2014c Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 07:12:13 -0400 Subject: [PATCH 06/19] refactor: relocate info view integration test --- .../management/integration => management/tests}/__init__.py | 0 eox_theming/management/tests/integration/__init__.py | 0 .../management => management/tests}/integration/test_views.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename eox_theming/{tests/management/integration => management/tests}/__init__.py (100%) create mode 100644 eox_theming/management/tests/integration/__init__.py rename eox_theming/{tests/management => management/tests}/integration/test_views.py (100%) diff --git a/eox_theming/tests/management/integration/__init__.py b/eox_theming/management/tests/__init__.py similarity index 100% rename from eox_theming/tests/management/integration/__init__.py rename to eox_theming/management/tests/__init__.py diff --git a/eox_theming/management/tests/integration/__init__.py b/eox_theming/management/tests/integration/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eox_theming/tests/management/integration/test_views.py b/eox_theming/management/tests/integration/test_views.py similarity index 100% rename from eox_theming/tests/management/integration/test_views.py rename to eox_theming/management/tests/integration/test_views.py From 5615bdabe2616a922864c92c031808be9a54b65c Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 07:32:50 -0400 Subject: [PATCH 07/19] chore: add requests and djangorestframework to test requirements --- requirements/test.in | 2 ++ requirements/test.txt | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/requirements/test.in b/requirements/test.in index d95462f..1eeb232 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -2,6 +2,7 @@ -r base.txt Django +djangorestframework mock pylint pytest @@ -12,4 +13,5 @@ coverage mako path-py testfixtures +requests pyyaml diff --git a/requirements/test.txt b/requirements/test.txt index 1e6a8e0..14ab424 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -17,6 +17,11 @@ backports-zoneinfo==0.2.1 ; python_version < "3.9" # -c requirements/constraints.txt # -r requirements/base.txt # django + # djangorestframework +certifi==2024.8.30 + # via requests +charset-normalizer==3.4.0 + # via requests coverage==7.6.1 # via -r requirements/test.in dill==0.3.9 @@ -25,10 +30,15 @@ dill==0.3.9 # -c https://raw.githubusercontent.com/openedx/edx-lint/master/edx_lint/files/common_constraints.txt # -r requirements/base.txt # -r requirements/test.in + # djangorestframework +djangorestframework==3.15.2 + # via -r requirements/test.in eox-tenant==11.7.0 # via -r requirements/base.txt exceptiongroup==1.2.2 # via pytest +idna==3.10 + # via requests iniconfig==2.0.0 # via pytest isort==5.13.2 @@ -63,6 +73,8 @@ pytest-django==4.9.0 # via -r requirements/test.in pyyaml==6.0.2 # via -r requirements/test.in +requests==2.32.3 + # via -r requirements/test.in six==1.16.0 # via -r requirements/base.txt sqlparse==0.5.1 @@ -83,3 +95,5 @@ typing-extensions==4.12.2 # asgiref # astroid # pylint +urllib3==2.2.3 + # via requests From 7a91541d424e05b43a1b3400dbea625d3f6f2d32 Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 07:36:46 -0400 Subject: [PATCH 08/19] chore: add drf constraint --- requirements/constraints.txt | 6 +++++- requirements/test.txt | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 80f54ee..bec98f4 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -12,4 +12,8 @@ -c https://raw.githubusercontent.com/openedx/edx-lint/master/edx_lint/files/common_constraints.txt # backports.zoneinfo is only needed for Python < 3.9 -backports.zoneinfo; python_version<'3.9' \ No newline at end of file +backports.zoneinfo; python_version<'3.9' + +# Adding pin to avoid any major upgrade. +# 3.15.1 is the latest version that works with Django 3.2 +djangorestframework<3.15.2 diff --git a/requirements/test.txt b/requirements/test.txt index 14ab424..b77dd00 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -31,8 +31,10 @@ dill==0.3.9 # -r requirements/base.txt # -r requirements/test.in # djangorestframework -djangorestframework==3.15.2 - # via -r requirements/test.in +djangorestframework==3.15.1 + # via + # -c requirements/constraints.txt + # -r requirements/test.in eox-tenant==11.7.0 # via -r requirements/base.txt exceptiongroup==1.2.2 From 7864869c031c584f266a72d8c1895245260c70d7 Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 07:40:34 -0400 Subject: [PATCH 09/19] fix: script to execute integration tests --- scripts/execute_integration_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/execute_integration_tests.sh b/scripts/execute_integration_tests.sh index 066dfac..c1f256c 100644 --- a/scripts/execute_integration_tests.sh +++ b/scripts/execute_integration_tests.sh @@ -1,3 +1,3 @@ #!/bin/bash -run-integration-tests +make run-integration-tests From 3a782849ac9074e2a399ca0173b34a1c14e58f93 Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 07:55:42 -0400 Subject: [PATCH 10/19] fix: integration tests target --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bb782b6..7e92461 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,7 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy sed '/^[dD]jango==/d;' requirements/test.txt > requirements/test.tmp mv requirements/test.tmp requirements/test.txt -run-integration-tests: - install-dev-dependencies +run-integration-tests: install-dev-dependencies pytest -rPf ./eox_theming/tests/management/integration quality: clean ## check coding style with pycodestyle and pylint From cb082e7d2431b5af5016e24a0d8657c1f33f890a Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 08:32:43 -0400 Subject: [PATCH 11/19] fix: add eox-tenant as extra requirements --- .github/workflows/integration-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 8ca3fec..0262fbb 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -14,5 +14,6 @@ jobs: with: tutor_version: ${{ matrix.tutor_version }} app_name: 'eox-theming' + openedx_extra_pip_requirements: 'eox-tenant' shell_file_to_run: 'scripts/execute_integration_tests.sh' openedx_imports_test_file_path: 'eox_theming/edxapp_wrapper/tests/integration/test_backends.py' From 9e0399bd125dfbd8e7dddf353e2dab84b62cda71 Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 08:36:37 -0400 Subject: [PATCH 12/19] fix: tox ini file --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index bc413ac..ab2b3b3 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,6 @@ envdir= deps = django32: -r requirements/django32.txt django42: -r requirements/django42.txt - -rrequirements/test.txt + -r requirements/test.txt commands = {posargs} From 2cb17443f15990b47566d7c570b4a2229afc290a Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 14:58:52 -0400 Subject: [PATCH 13/19] fix: makefile target for integration tests --- .github/workflows/integration-test.yml | 1 - Makefile | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 0262fbb..8ca3fec 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -14,6 +14,5 @@ jobs: with: tutor_version: ${{ matrix.tutor_version }} app_name: 'eox-theming' - openedx_extra_pip_requirements: 'eox-tenant' shell_file_to_run: 'scripts/execute_integration_tests.sh' openedx_imports_test_file_path: 'eox_theming/edxapp_wrapper/tests/integration/test_backends.py' diff --git a/Makefile b/Makefile index 7e92461..b9b663d 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,6 @@ requirements: ## install environment requirements install-dev-dependencies: ## install tox pip install -r requirements/tox.txt - pip install -r requirements/test.txt upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in @@ -42,7 +41,8 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy sed '/^[dD]jango==/d;' requirements/test.txt > requirements/test.tmp mv requirements/test.tmp requirements/test.txt -run-integration-tests: install-dev-dependencies +run-integration-tests: + pip install -r requirements/test.txt pytest -rPf ./eox_theming/tests/management/integration quality: clean ## check coding style with pycodestyle and pylint From ab3383d9f3a647d6ba5d7a222686d50bb573d97a Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 15:28:39 -0400 Subject: [PATCH 14/19] chore(ci): install setuptools and improve info view test --- Makefile | 3 +++ .../management/tests/integration/test_views.py | 11 +++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index b9b663d..a04e7da 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,9 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy mv requirements/test.tmp requirements/test.txt run-integration-tests: +# Install setuptools before running tests because pkg_resources is used +# in paths.py, which is required by the apps.py `ready()` method. + pip install setuptools pip install -r requirements/test.txt pytest -rPf ./eox_theming/tests/management/integration diff --git a/eox_theming/management/tests/integration/test_views.py b/eox_theming/management/tests/integration/test_views.py index 460a1c7..5e91ce8 100644 --- a/eox_theming/management/tests/integration/test_views.py +++ b/eox_theming/management/tests/integration/test_views.py @@ -15,13 +15,6 @@ class TestInfoView(TestCase): Integration test suite for the info view. """ - def setUp(self) -> None: - """ - Set up the test suite. - """ - self.url = f"{settings['EOX_THEMING_BASE_URL']}{reverse('eox-info')}" - super().setUp() - def test_info_view_success(self) -> None: """Test the info view. @@ -29,7 +22,9 @@ def test_info_view_success(self) -> None: - The status code is 200. - The response contains the version, name and git commit hash. """ - response = requests.get(self.url, timeout=settings["API_TIMEOUT"]) + url = f"{settings['EOX_THEMING_BASE_URL']}{reverse('eox-info')}" + + response = requests.get(url, timeout=settings["API_TIMEOUT"]) response_data = response.json() self.assertEqual(response.status_code, status.HTTP_200_OK) From 99577199d169d6c5d3f409071aa6fc1bb16f6118 Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 15:43:04 -0400 Subject: [PATCH 15/19] fix: makefile target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a04e7da..646f451 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ run-integration-tests: # in paths.py, which is required by the apps.py `ready()` method. pip install setuptools pip install -r requirements/test.txt - pytest -rPf ./eox_theming/tests/management/integration + pytest -rPf ./eox_theming/management/tests/integration quality: clean ## check coding style with pycodestyle and pylint $(TOX) pycodestyle ./eox_theming From 522a9aa917ccf7caae2df626aeba08baf0dedc16 Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 17:11:07 -0400 Subject: [PATCH 16/19] fix: eox-info re_path for reverse use --- eox_theming/management/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eox_theming/management/urls.py b/eox_theming/management/urls.py index 2295da5..fc93fc0 100644 --- a/eox_theming/management/urls.py +++ b/eox_theming/management/urls.py @@ -6,5 +6,5 @@ from eox_theming.management import views urlpatterns = [ - re_path(r'^eox-info$', views.info_view), + re_path(r'^eox-info$', views.info_view, name='eox-info'), ] From 62be9962e143b589df28308c50e6e4536ac7ae1d Mon Sep 17 00:00:00 2001 From: magajh Date: Tue, 15 Oct 2024 18:23:33 -0400 Subject: [PATCH 17/19] fix: info view integration test --- eox_theming/management/tests/integration/test_views.py | 2 +- eox_theming/settings/test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eox_theming/management/tests/integration/test_views.py b/eox_theming/management/tests/integration/test_views.py index 5e91ce8..3043aaa 100644 --- a/eox_theming/management/tests/integration/test_views.py +++ b/eox_theming/management/tests/integration/test_views.py @@ -22,7 +22,7 @@ def test_info_view_success(self) -> None: - The status code is 200. - The response contains the version, name and git commit hash. """ - url = f"{settings['EOX_THEMING_BASE_URL']}{reverse('eox-info')}" + url = f"{settings['EOX_THEMING_BASE_URL']}{reverse('eox-theming-management:eox-info')}" response = requests.get(url, timeout=settings["API_TIMEOUT"]) diff --git a/eox_theming/settings/test.py b/eox_theming/settings/test.py index fe77634..de99bc5 100644 --- a/eox_theming/settings/test.py +++ b/eox_theming/settings/test.py @@ -79,6 +79,6 @@ def plugin_settings(settings): # pylint: disable=function-redefined # Integration tests settings INTEGRATION_TEST_SETTINGS = { # Retrieved from the Tutor environment where the integration tests run - "EOX_THEMING_BASE_URL": f"http://{os.environ.get('LMS_HOST', 'local.edly.io')}/eox-tenant", + "EOX_THEMING_BASE_URL": f"http://{os.environ.get('LMS_HOST', 'local.edly.io')}/eox-theming", "API_TIMEOUT": 5, } From 8e904f0a5f782b310829f9f91b56d119160d7e84 Mon Sep 17 00:00:00 2001 From: magajh Date: Thu, 17 Oct 2024 08:32:55 -0400 Subject: [PATCH 18/19] fix: use main branch in integration tests action --- .github/workflows/integration-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 8ca3fec..48d2e5e 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -10,7 +10,7 @@ jobs: tutor_version: ['<18.0.0', '<19.0.0', 'nightly'] steps: - name: Run Integration Tests - uses: eduNEXT/integration-test-in-tutor@mjh/make-extra-reqs-step-optional + uses: eduNEXT/integration-test-in-tutor@main with: tutor_version: ${{ matrix.tutor_version }} app_name: 'eox-theming' From 0e0253a19a15f135873f0c08832843a0f349e8de Mon Sep 17 00:00:00 2001 From: magajh Date: Thu, 17 Oct 2024 13:17:27 -0400 Subject: [PATCH 19/19] chore(ci): remove shell_file_to_run input --- .github/workflows/integration-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 48d2e5e..c27ce49 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -14,5 +14,4 @@ jobs: with: tutor_version: ${{ matrix.tutor_version }} app_name: 'eox-theming' - shell_file_to_run: 'scripts/execute_integration_tests.sh' openedx_imports_test_file_path: 'eox_theming/edxapp_wrapper/tests/integration/test_backends.py'