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

feat: add tutor integration test #104

Merged
merged 11 commits into from
Jun 12, 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
19 changes: 19 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Tutor Integration Tests
on: [pull_request]

jobs:
integration-test:
name: Tutor Integration Tests
runs-on: ubuntu-latest
strategy:
matrix:
tutor_version: ["<17.0.0", "<18.0.0"]
steps:
- uses: actions/checkout@v4
with:
path: eox-tagging
- uses: eduNEXT/integration-test-in-tutor@main
with:
tutor_version: ${{ matrix.tutor_version }}
app_name: "eox-tagging"
shell_file_to_run: "eox_tagging/test/tutor/integration.sh"
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
Backend CourseOverview file, here are all the methods from
openedx.core.djangoapps.content.course_overviews.
"""
from openedx.core.djangoapps.content.course_overviews.models import \
CourseOverview # pylint: disable=import-outside-toplevel, import-error


def get_course_overview():
"""Backend to get course overview."""
from openedx.core.djangoapps.content.course_overviews.models import \
CourseOverview # pylint: disable=import-outside-toplevel, import-error

return CourseOverview
2 changes: 1 addition & 1 deletion eox_tagging/edxapp_wrappers/backends/enrollment_l_v1.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Backend for course enrollments valid for lilac release.
"""
from common.djangoapps.student.models import CourseEnrollment # pylint: disable=C0415, E0401


def get_enrollment_object():
"""Backend to get course enrollment."""
from common.djangoapps.student.models import CourseEnrollment # pylint: disable=C0415, E0401
return CourseEnrollment
12 changes: 12 additions & 0 deletions eox_tagging/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"""
from __future__ import unicode_literals

import codecs
import os

import yaml

from .common import * # pylint: disable=wildcard-import, unused-wildcard-import


Expand Down Expand Up @@ -46,6 +51,13 @@ def plugin_settings(settings): # pylint: disable=function-redefined
settings.EOX_TAGGING_GET_ENROLLMENT_OBJECT = "eox_tagging.edxapp_wrappers.backends.enrollment_l_v1_test"
settings.TEST_SITE = 1

# setup the databases used in the tutor local environment
lms_cfg = os.environ.get('LMS_CFG')
if lms_cfg:
with codecs.open(lms_cfg, encoding='utf-8') as file:
env_tokens = yaml.safe_load(file)
settings.DATABASES = env_tokens['DATABASES']


SETTINGS = SettingsClass()
plugin_settings(SETTINGS)
Expand Down
Empty file.
16 changes: 16 additions & 0 deletions eox_tagging/test/tutor/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
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
"""
17 changes: 17 additions & 0 deletions eox_tagging/test/tutor/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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-tagging

echo "Install test-requirements"
make test-requirements

echo "Install eox-core(requirement)"
pip install eox-core

python manage.py lms makemigrations
python manage.py lms migrate

echo "Run tests"
pytest -s --ds=lms.envs.tutor.test /openedx/eox-tagging/eox_tagging/test/tutor
19 changes: 19 additions & 0 deletions eox_tagging/test/tutor/integration_test_tutor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Test integration file.
"""
from django.test import TestCase


class TutorIntegrationTestCase(TestCase):
"""
Tests integration with openedx
"""

# 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
"""
import eox_tagging.edxapp_wrappers.backends.course_overview_i_v1 # isort:skip
import eox_tagging.edxapp_wrappers.backends.bearer_authentication_i_v1 # isort:skip
import eox_tagging.edxapp_wrappers.backends.enrollment_l_v1 # isort:skip
7 changes: 7 additions & 0 deletions eox_tagging/test/tutor/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[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:
1 change: 1 addition & 0 deletions requirements/test.in
BryanttV marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ django-filter
django-oauth2-provider
djangorestframework-oauth
mock
pyyaml
Loading