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 testing workflow and add pytest configuration #110

Merged
merged 14 commits into from
Oct 17, 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
12 changes: 5 additions & 7 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ jobs:
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-tagging
- 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-tagging"
shell_file_to_run: "eox_tagging/test/tutor/integration.sh"
app_name: 'eox-tagging'
openedx_imports_test_file_path: 'eox_tagging/edxapp_wrappers/tests/integration/test_backends.py'
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ requirements: ## install environment requirements
pip install -r requirements/base.txt

test_requirements:
pip install -r requirements/test.txt -r requirements/django.txt
pip install -r requirements/test.txt

docs_requirements:
pip install -r requirements/docs.txt
Expand All @@ -46,13 +46,16 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
$(PIP_COMPILE) -o requirements/tox.txt requirements/tox.in
$(PIP_COMPILE) -o requirements/docs.txt requirements/docs.in

grep -e "^django==" requirements/test.txt > requirements/django.txt
grep -e "^django==" requirements/test.txt > requirements/django42.txt
sed '/^[dD]jango==/d;' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt

run-integration-tests: test_requirements
pytest -rPf ./eox_tagging/test/integration --ignore=test_api_integration.py

test-python: clean ## Run test suite.
$(TOX) pip install -r requirements/test.txt --exists-action w
$(TOX) coverage run --source ./eox_tagging manage.py test
$(TOX) coverage run --source="." -m pytest ./eox_tagging --ignore-glob='**/integration/*'
$(TOX) coverage report -m --fail-under=71

quality: clean ## Run quality test.
Expand Down
Empty file.
13 changes: 13 additions & 0 deletions eox_tagging/edxapp_wrappers/tests/integration/test_backends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
This module contains tests for 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_tagging.edxapp_wrappers.backends.bearer_authentication_i_v1
import eox_tagging.edxapp_wrappers.backends.course_overview_i_v1
import eox_tagging.edxapp_wrappers.backends.enrollment_l_v1
8 changes: 8 additions & 0 deletions eox_tagging/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ def plugin_settings(settings): # pylint: disable=function-redefined
SETTINGS = SettingsClass()
plugin_settings(SETTINGS)
vars().update(SETTINGS.__dict__)


# Integration test settings
INTEGRATION_TEST_SETTINGS = {
# Retrieved from the Tutor environment where the integration tests run
"EOX_TAGGING_BASE_URL": f"http://{os.environ.get('LMS_HOST', 'local.edly.io')}/eox-tagging",
"API_TIMEOUT": 5,
}
33 changes: 33 additions & 0 deletions eox_tagging/test/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_TAGGING_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)
self.assertIn("version", response_data)
self.assertIn("name", response_data)
self.assertIn("git", response_data)
16 changes: 0 additions & 16 deletions eox_tagging/test/tutor/conftest.py

This file was deleted.

17 changes: 0 additions & 17 deletions eox_tagging/test/tutor/integration.sh

This file was deleted.

41 changes: 0 additions & 41 deletions eox_tagging/test/tutor/integration_test_tutor.py

This file was deleted.

7 changes: 0 additions & 7 deletions eox_tagging/test/tutor/pytest.ini

This file was deleted.

22 changes: 15 additions & 7 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# make upgrade
Expand All @@ -12,6 +12,13 @@ asgiref==3.8.1
# via django
attrs==24.2.0
# via openedx-events
backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# celery
# django
# djangorestframework
# kombu
billiard==4.2.1
# via celery
celery==5.4.0
Expand All @@ -24,7 +31,7 @@ cffi==1.17.1
# via
# cryptography
# pynacl
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via requests
click==8.1.7
# via
Expand Down Expand Up @@ -124,7 +131,7 @@ edx-api-doc-tools==2.0.0
# via eox-core
edx-ccx-keys==1.3.0
# via openedx-events
edx-django-utils==5.15.0
edx-django-utils==6.0.0
# via
# edx-drf-extensions
# edx-rest-api-client
Expand All @@ -146,7 +153,7 @@ edx-opaque-keys[django]==2.11.0
# edx-when
# eox-core
# openedx-events
edx-proctoring==4.18.1
edx-proctoring==4.18.2
# via eox-core
edx-rest-api-client==6.0.0
# via edx-proctoring
Expand Down Expand Up @@ -185,7 +192,7 @@ markupsafe==2.1.5
# jinja2
# mako
# xblock
newrelic==9.13.0
newrelic==10.1.0
# via edx-django-utils
oauthlib==3.2.2
# via
Expand All @@ -206,7 +213,7 @@ psutil==6.0.0
# via edx-django-utils
pycparser==2.22
# via cffi
pycryptodomex==3.20.0
pycryptodomex==3.21.0
# via edx-proctoring
pyjwt[crypto]==2.9.0
# via
Expand Down Expand Up @@ -284,10 +291,11 @@ typing-extensions==4.12.2
# asgiref
# edx-opaque-keys
# jwcrypto
# kombu
tzdata==2024.2
# via
# backports-zoneinfo
# celery
# kombu
uritemplate==4.1.1
# via drf-yasg
urllib3==2.2.3
Expand Down
5 changes: 4 additions & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ django-filter<24.1
djangorestframework<3.15.2

# Latest version compatible with Django 3.2
django-oauth-toolkit==2.4.0
django-oauth-toolkit==2.4.0

# backports.zoneinfo is only needed for Python < 3.9
backports.zoneinfo; python_version<'3.9'
28 changes: 16 additions & 12 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# make upgrade
#
alabaster==1.0.0
alabaster==0.7.13
# via sphinx
babel==2.16.0
# via sphinx
certifi==2024.8.30
# via requests
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via requests
docutils==0.21.2
docutils==0.20.1
# via sphinx
idna==3.10
# via requests
imagesize==1.4.1
# via sphinx
importlib-metadata==8.5.0
# via sphinx
jinja2==3.1.4
# via sphinx
markupsafe==2.1.5
Expand All @@ -26,25 +28,27 @@ packaging==24.1
# via sphinx
pygments==2.18.0
# via sphinx
pytz==2024.2
# via babel
requests==2.32.3
# via sphinx
snowballstemmer==2.2.0
# via sphinx
sphinx==8.0.2
sphinx==7.1.2
# via -r requirements/docs.in
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-applehelp==1.0.4
# via sphinx
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-devhelp==1.0.2
# via sphinx
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-htmlhelp==2.0.1
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==2.0.0
# via sphinx
sphinxcontrib-serializinghtml==2.0.0
sphinxcontrib-qthelp==1.0.3
# via sphinx
tomli==2.0.1
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
urllib3==2.2.3
# via requests
zipp==3.20.2
# via importlib-metadata
12 changes: 8 additions & 4 deletions requirements/pip-tools.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# make upgrade
#
build==1.2.2
build==1.2.2.post1
# via pip-tools
click==8.1.7
# via pip-tools
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.44.0
# via pip-tools
zipp==3.20.2
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
5 changes: 3 additions & 2 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

Django
edx-opaque-keys[django]
# Use palm version for pylint to avoid errors
pylint==2.15.10
pylint
pytest
pytest-django
pycodestyle
coverage
django-fake-model
Expand Down
Loading
Loading