Skip to content

Commit

Permalink
feat: add test integration (#50)
Browse files Browse the repository at this point in the history
* feat: add test integration

* fix: remove commit

* feat: add test integration

* fix: pylint fixes

* fix: pylint fixes

* fix: pylint fixes

* fix: pylint fixes

* fix: pylint fixes

* fix: pylint fixes

* fix: pylint fixes

* fix: pylint fixes

* fix: pylint fixes

* fix: remove unused function to test integration

* fix: pylint fixes

* fix: ignore pylint integration file

* fix: pylint fixes

* fix: pylint fixes

* fix: ignore pylint integration file

* fix: ignore pylint integration file

* fix: ignore pylint integration file

* fix: ignore pylint integration file

* fix: ignore pylint integration file

* fix: refactor integration test

* fix: refactor integration test

* fix: refactor integration test

* fix: pylint error

* fix: remove pylint ignore

* fix: comment test settings

* fix: comment test settings

* fix: comment test settings

* fix: comment test settings
  • Loading branch information
luisfelipec95 authored May 24, 2024
1 parent ff81da1 commit bfad685
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 13 deletions.
2 changes: 1 addition & 1 deletion eox_hooks/edxapp_wrapper/backends/course_modes_j_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backend file for Course Modes related objects.
"""
from course_modes.models import CourseMode # pylint: disable=C0415, E0401


def get_all_course_modes():
Expand All @@ -10,6 +11,5 @@ def get_all_course_modes():
Returns:
[list]: list of course modes.
"""
from course_modes.models import CourseMode # pylint: disable=C0415, E0401
modes_for_course = CourseMode.ALL_MODES
return modes_for_course
2 changes: 1 addition & 1 deletion eox_hooks/edxapp_wrapper/backends/course_modes_l_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backend file for Course Modes related objects.
"""
from common.djangoapps.course_modes.models import CourseMode # pylint: disable=C0415, E0401


def get_all_course_modes():
Expand All @@ -10,6 +11,5 @@ def get_all_course_modes():
Returns:
[list]: list of course modes.
"""
from common.djangoapps.course_modes.models import CourseMode # pylint: disable=C0415, E0401
modes_for_course = CourseMode.ALL_MODES
return modes_for_course
2 changes: 1 addition & 1 deletion eox_hooks/edxapp_wrapper/backends/courses_j_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backend file for Course related objects.
"""
from courseware.module_render import load_single_xblock # pylint: disable=C0415, E0401


def get_load_single_xblock():
Expand All @@ -10,7 +11,6 @@ def get_load_single_xblock():
Returns:
[Function]: load_single_xblock function.
"""
from courseware.module_render import load_single_xblock # pylint: disable=C0415, E0401
return load_single_xblock


Expand Down
4 changes: 2 additions & 2 deletions eox_hooks/edxapp_wrapper/backends/courses_l_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Backend file for Course related objects.
"""
from lms.djangoapps.courseware.module_render import load_single_xblock # pylint: disable=C0415, E0401
from xmodule.modulestore.exceptions import ItemNotFoundError # pylint: disable=C0415, E0401


def get_load_single_xblock():
Expand All @@ -10,7 +12,6 @@ def get_load_single_xblock():
Returns:
[Function]: load_single_xblock function.
"""
from lms.djangoapps.courseware.module_render import load_single_xblock # pylint: disable=C0415, E0401
return load_single_xblock


Expand All @@ -21,5 +22,4 @@ def get_item_not_found_exception():
Returns:
[Class]: ItemNotFoundError exception.
"""
from xmodule.modulestore.exceptions import ItemNotFoundError # pylint: disable=C0415, E0401
return ItemNotFoundError
4 changes: 2 additions & 2 deletions eox_hooks/edxapp_wrapper/backends/courses_p_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Backend file for Course related objects.
"""
from lms.djangoapps.courseware.block_render import load_single_xblock # pylint: disable=C0415, E0401
from xmodule.modulestore.exceptions import ItemNotFoundError # pylint: disable=C0415, E0401


def get_load_single_xblock():
Expand All @@ -10,7 +12,6 @@ def get_load_single_xblock():
Returns:
[Function]: load_single_xblock function.
"""
from lms.djangoapps.courseware.block_render import load_single_xblock # pylint: disable=C0415, E0401
return load_single_xblock


Expand All @@ -21,5 +22,4 @@ def get_item_not_found_exception():
Returns:
[Class]: ItemNotFoundError exception.
"""
from xmodule.modulestore.exceptions import ItemNotFoundError # pylint: disable=C0415, E0401
return ItemNotFoundError
2 changes: 1 addition & 1 deletion eox_hooks/edxapp_wrapper/backends/enrollments_j_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backend file for Course Enrollment related objects.
"""
from student.models import CourseEnrollment # pylint: disable=C0415, E0401


def get_course_enrollment():
Expand All @@ -10,5 +11,4 @@ def get_course_enrollment():
Returns:
[Class]: Course Enrollment edxapp model.
"""
from student.models import CourseEnrollment # pylint: disable=C0415, E0401
return CourseEnrollment
2 changes: 1 addition & 1 deletion eox_hooks/edxapp_wrapper/backends/enrollments_l_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backend file for Course Enrollment related objects.
"""
from common.djangoapps.student.models import CourseEnrollment # pylint: disable=C0415, E0401


def get_course_enrollment():
Expand All @@ -10,5 +11,4 @@ def get_course_enrollment():
Returns:
[Class]: Course Enrollment edxapp model.
"""
from common.djangoapps.student.models import CourseEnrollment # pylint: disable=C0415, E0401
return CourseEnrollment
4 changes: 2 additions & 2 deletions eox_hooks/edxapp_wrapper/backends/models_j_v1.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
Simple backend that returns the platform's models
"""
from lms.djangoapps.certificates.models import GeneratedCertificate # pylint: disable=C0415, E0401
from student.models import UserProfile # pylint: disable=C0415, E0401


def get_certificate_model():
"""Return the GeneratedCertificate model class when called during runtime"""
from lms.djangoapps.certificates.models import GeneratedCertificate # pylint: disable=C0415, E0401
return GeneratedCertificate


def get_user_profile_model():
"""Return the UserProfile model class when called during runtime"""
from student.models import UserProfile # pylint: disable=C0415, E0401
return UserProfile
4 changes: 2 additions & 2 deletions eox_hooks/edxapp_wrapper/backends/models_l_v1.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
Simple backend that returns the platform's models
"""
from common.djangoapps.student.models import UserProfile # pylint: disable=C0415, E0401
from lms.djangoapps.certificates.models import GeneratedCertificate # pylint: disable=C0415, E0401


def get_certificate_model():
"""Return the GeneratedCertificate model class when called during runtime"""
from lms.djangoapps.certificates.models import GeneratedCertificate # pylint: disable=C0415, E0401
return GeneratedCertificate


def get_user_profile_model():
"""Return the UserProfile model class when called during runtime"""
from common.djangoapps.student.models import UserProfile # pylint: disable=C0415, E0401
return UserProfile
14 changes: 14 additions & 0 deletions eox_hooks/settings/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""
Test Django settings for eox_hooks project.
"""
import codecs
import os

import yaml

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

Expand Down Expand Up @@ -43,3 +46,14 @@
'NAME': 'db.sqlite3',
}
}


def plugin_settings(settings): # pylint: disable=function-redefined
"""
For the platform tests
"""
# setup the databases used in the tutor local environment
if os.environ['LMS_CFG']:
with codecs.open(os.environ['LMS_CFG'], encoding='utf-8') as f:
env_tokens = yaml.safe_load(f)
settings.DATABASES = env_tokens['DATABASES']
Empty file.
16 changes: 16 additions & 0 deletions eox_hooks/tests/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
"""
20 changes: 20 additions & 0 deletions eox_hooks/tests/tutor/integration_test_tutor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
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_hooks.edxapp_wrapper.backends.course_modes_l_v1 # isort:skip
import eox_hooks.edxapp_wrapper.backends.courses_p_v1 # isort:skip
import eox_hooks.edxapp_wrapper.backends.enrollments_l_v1 # isort:skip
import eox_hooks.edxapp_wrapper.backends.models_l_v1 # isort:skip
7 changes: 7 additions & 0 deletions eox_hooks/tests/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
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage
mock
testfixtures
requests
pyyaml
2 changes: 2 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pymongo==3.13.0
# via
# -r requirements/base.txt
# edx-opaque-keys
pyyaml==6.0.1
# via -r requirements/test.in
python-dateutil==2.8.2
# via
# -r requirements/base.txt
Expand Down

0 comments on commit bfad685

Please sign in to comment.