Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update integration tests workflow and add pytest configuration #66

Merged
merged 19 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ 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@main
with:
tutor_version: ${{ matrix.tutor_version }}
app_name: "eox-theming"
shell_file_to_run: "eox_theming/tests/tutor/integration.sh"
app_name: 'eox-theming'
openedx_imports_test_file_path: 'eox_theming/edxapp_wrapper/tests/integration/test_backends.py'
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ 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 setuptools before running tests because pkg_resources is used
# in paths.py, which is required by the apps.py `ready()` method.
pip install setuptools
MaferMazu marked this conversation as resolved.
Show resolved Hide resolved
pip install -r requirements/test.txt
pytest -rPf ./eox_theming/management/tests/integration

quality: clean ## check coding style with pycodestyle and pylint
$(TOX) pycodestyle ./eox_theming
$(TOX) pylint ./eox_theming --rcfile=./setup.cfg
$(TOX) isort --check-only --diff ./eox_theming

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
Empty file.
17 changes: 17 additions & 0 deletions eox_theming/edxapp_wrapper/tests/integration/test_backends.py
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions eox_theming/management/tests/integration/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
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 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.
"""
url = f"{settings['EOX_THEMING_BASE_URL']}{reverse('eox-theming-management:eox-info')}"

response = requests.get(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)
2 changes: 1 addition & 1 deletion eox_theming/management/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]
8 changes: 8 additions & 0 deletions eox_theming/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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-theming",
"API_TIMEOUT": 5,
}
16 changes: 0 additions & 16 deletions eox_theming/tests/tutor/conftest.py

This file was deleted.

11 changes: 0 additions & 11 deletions eox_theming/tests/tutor/integration.sh

This file was deleted.

24 changes: 0 additions & 24 deletions eox_theming/tests/tutor/integration_test_tutor.py

This file was deleted.

7 changes: 0 additions & 7 deletions eox_theming/tests/tutor/pytest.ini

This file was deleted.

2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'
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
16 changes: 7 additions & 9 deletions requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
-r base.txt

Django
djangorestframework
mock
pylint
pytest
pytest-django
astroid
pycodestyle
coverage
mako
path-py
testfixtures
requests
pyyaml
50 changes: 41 additions & 9 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,32 @@ backports-zoneinfo==0.2.1 ; python_version < "3.9"
# -c requirements/constraints.txt
# -r requirements/base.txt
# django
coverage==7.6.0
# 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.8
dill==0.3.9
# via pylint
# via
# -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.1
# via
# -c requirements/constraints.txt
# -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
# via pylint
mako==1.3.5
Expand All @@ -37,17 +53,29 @@ 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.7
# via -r requirements/test.in
pytest==8.3.3
# via
# -r requirements/test.in
# pytest-django
pytest-django==4.9.0
# via -r requirements/test.in
pylint==3.2.6
pyyaml==6.0.2
# via -r requirements/test.in
pyyaml==6.0.1
requests==2.32.3
# via -r requirements/test.in
six==1.16.0
# via -r requirements/base.txt
Expand All @@ -57,13 +85,17 @@ 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
# -r requirements/base.txt
# asgiref
# astroid
# pylint
urllib3==2.2.3
# via requests
18 changes: 10 additions & 8 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,37 @@
#
# 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
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
3 changes: 3 additions & 0 deletions scripts/execute_integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

make run-integration-tests
Loading
Loading