Skip to content

Commit

Permalink
refactor: create file for backend and info view integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
magajh committed Oct 15, 2024
1 parent 1d36186 commit 1d8fe63
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 89 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ 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'
shell_file_to_run: 'scripts/execute_integration_tests.sh'
openedx_imports_test_file_path: 'eox_tagging/edxapp_wrapper/tests/integration/test_backends.py'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy

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
File renamed without changes.
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,
}
39 changes: 39 additions & 0 deletions eox_tagging/test/integration/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
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_TAGGING_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)

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.

7 changes: 7 additions & 0 deletions scripts/execute_integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

echo "Install test-requirements"
make install-dev-dependencies

echo "Run tests"
pytest -rPf ./eox_tagging/test/integration --ignore=test_api_integration.py
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ tag = False

[bumpversion:file:eox_tagging/__init__.py]

[tool:pytest]
DJANGO_SETTINGS_MODULE = eox_tagging.settings.test

[coverage:run]
data_file = .coverage
omit =
Expand Down

0 comments on commit 1d8fe63

Please sign in to comment.