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 #221

Merged
merged 28 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9668b7a
refactor(ci): update workflow, script, and tests to use latest action…
magajh Oct 3, 2024
95cc896
fix: pytest path
magajh Oct 3, 2024
06ffa33
fix: install-dev-dependencies target
magajh Oct 3, 2024
11da85c
fix: test-python target
magajh Oct 3, 2024
112c4bd
fix: remove self from backend test
magajh Oct 3, 2024
6c1bcef
chore: add pytest and pytest-django to test requirements
magajh Oct 3, 2024
2c3570f
fix: remove fixtures file
magajh Oct 3, 2024
dc0d7e5
fix: integration tests
magajh Oct 3, 2024
45a24b1
fix: include settings file for python unit tests
magajh Oct 3, 2024
1405276
fix: typo
magajh Oct 3, 2024
1ba6d77
fix: install dev dependencies
magajh Oct 3, 2024
f912364
fix: quality
magajh Oct 3, 2024
1c4b081
fix: app name
magajh Oct 3, 2024
53531c8
fix: use branch with optional extra requirements
magajh Oct 11, 2024
511b2fa
chore(ci): remove integration tests for nightly
magajh Oct 11, 2024
3e1cc95
fix: quality
magajh Oct 11, 2024
9695ae3
fix: set default config file for Pytest
magajh Oct 13, 2024
4bc28b8
fix: add EOX_TENANT_BASE_URL setting
magajh Oct 14, 2024
140614d
feat: add type hint to setup class
magajh Oct 14, 2024
edaa7a8
fix: run integration tests in nightly
magajh Oct 14, 2024
6b2ed2a
fix: upgrade requirements with py3.8
magajh Oct 14, 2024
6bf6854
fix: undo change in coverage configs
magajh Oct 14, 2024
1b65bd2
fix: run isort for backend tests
magajh Oct 14, 2024
af2e033
refactor: create makefile target to execute integration tests
magajh Oct 15, 2024
440e9b6
fix: integration tests target
magajh Oct 15, 2024
b00f9d6
fix: integration tests target in makefile
magajh Oct 15, 2024
6293075
fix: improve info view test
magajh Oct 16, 2024
d9325c8
chore(ci): use main branch from integration tests action and remove u…
magajh Oct 17, 2024
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-tenant
- 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-tenant"
shell_file_to_run: "eox_tenant/test/tutor/integration.sh"
app_name: 'eox-tenant'
openedx_imports_test_file_path: 'eox_tenant/edxapp_wrapper/tests/integration/test_backends.py'
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ 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:
pip install -r requirements/test.txt
pytest -rPf ./eox_tenant/test/integration

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

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

run-tests: test-python quality
Empty file.
18 changes: 18 additions & 0 deletions eox_tenant/edxapp_wrapper/tests/integration/test_backends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
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_tenant.edxapp_wrapper.backends.bearer_authentication_l_v1
import eox_tenant.edxapp_wrapper.backends.branding_api_l_v1
import eox_tenant.edxapp_wrapper.backends.edx_auth_n_v1
import eox_tenant.edxapp_wrapper.backends.edxmako_l_v1
import eox_tenant.edxapp_wrapper.backends.oauth_dispatch_j_v1
import eox_tenant.edxapp_wrapper.backends.site_configuration_module_i_v1
import eox_tenant.edxapp_wrapper.backends.theming_helpers_h_v1
import eox_tenant.edxapp_wrapper.backends.users_p_v1
8 changes: 8 additions & 0 deletions eox_tenant/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,11 @@ def plugin_settings(settings): # pylint: disable=function-redefined
with codecs.open(os.environ['LMS_CFG'], encoding='utf-8') as f:
env_tokens = yaml.safe_load(f)
settings.DATABASES = env_tokens['DATABASES']


# Integration test settings
INTEGRATION_TEST_SETTINGS = {
# Retrieved from the Tutor environment where the integration tests run
"EOX_TENANT_BASE_URL": f"http://{os.environ.get('LMS_HOST', 'local.edly.io')}/eox-tenant",
"API_TIMEOUT": 5,
}
Empty file.
33 changes: 33 additions & 0 deletions eox_tenant/test/integration/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Test integration file.
"""
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_TENANT_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_tenant/test/tutor/conftest.py

This file was deleted.

13 changes: 0 additions & 13 deletions eox_tenant/test/tutor/integration.sh

This file was deleted.

46 changes: 0 additions & 46 deletions eox_tenant/test/tutor/integration_test_tutor.py

This file was deleted.

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

This file was deleted.

38 changes: 19 additions & 19 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ backports-zoneinfo==0.2.1 ; python_version < "3.9"
# -c requirements/constraints.txt
# django
# djangorestframework
certifi==2024.6.2
certifi==2024.8.30
# via requests
cffi==1.16.0
cffi==1.17.1
# via
# cryptography
# pynacl
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via requests
click==8.1.7
# via edx-django-utils
cryptography==42.0.8
cryptography==43.0.1
# via
# pyjwt
# social-auth-core
defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
django==4.2.13
django==4.2.16
# via
# -c https://raw.githubusercontent.com/openedx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/constraints.txt
Expand All @@ -49,7 +49,7 @@ django-crum==0.7.9
# via
# -r requirements/base.in
# edx-django-utils
django-model-utils==4.5.1
django-model-utils==5.0.0
# via edx-organizations
django-mysql==4.14.0
# via -r requirements/base.in
Expand All @@ -72,45 +72,45 @@ dnspython==2.6.1
# via pymongo
drf-jwt==1.19.2
# via edx-drf-extensions
edx-django-utils==5.14.2
edx-django-utils==6.0.0
# via edx-drf-extensions
edx-drf-extensions==10.3.0
edx-drf-extensions==10.4.0
# via
# -r requirements/base.in
# edx-organizations
edx-opaque-keys[django]==2.10.0
edx-opaque-keys[django]==2.11.0
# via
# -r requirements/base.in
# edx-drf-extensions
# edx-organizations
edx-organizations==6.13.0
edx-organizations==7.0.0
# via -r requirements/base.in
idna==3.7
idna==3.10
# via requests
jsonfield==3.1.0
# via -r requirements/base.in
newrelic==9.11.0
newrelic==10.1.0
# via edx-django-utils
oauthlib==3.2.2
# via
# requests-oauthlib
# social-auth-core
openedx-filters==1.9.0
# via -r requirements/base.in
pbr==6.0.0
pbr==6.1.0
# via stevedore
pillow==10.3.0
pillow==10.4.0
# via edx-organizations
psutil==6.0.0
# via edx-django-utils
pycparser==2.22
# via cffi
pyjwt[crypto]==2.8.0
pyjwt[crypto]==2.9.0
# via
# drf-jwt
# edx-drf-extensions
# social-auth-core
pymongo==4.7.3
pymongo==4.10.1
# via edx-opaque-keys
pynacl==1.5.0
# via edx-django-utils
Expand All @@ -129,17 +129,17 @@ six==1.16.0
# via -r requirements/base.in
social-auth-core==4.5.4
# via -r requirements/base.in
sqlparse==0.5.0
sqlparse==0.5.1
# via django
stevedore==5.2.0
stevedore==5.3.0
# via
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.12.2
# via
# asgiref
# edx-opaque-keys
urllib3==2.2.2
urllib3==2.2.3
# via requests

# The following packages are considered to be unsafe in a requirements file:
Expand Down
4 changes: 4 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ 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

# Versions >= 3.3.0 drop support for Python 3.8
# Ensures a consistent pylint version across all Python environments to avoid triggering varying warnings
pylint<3.3.0
2 changes: 1 addition & 1 deletion requirements/django42.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django==4.2.13
django==4.2.16
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
2 changes: 2 additions & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ django-fake-model
ddt
pycodestyle
pylint
pytest
pytest-django
coverage
mock
testfixtures
Expand Down
Loading
Loading