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 integration tests for the enrollments api AP-1346 #280

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e344fd1
feat: add tutor command to import democourse
BryanttV Sep 19, 2024
7a8fe05
chore: add output in tests
BryanttV Sep 20, 2024
46774d4
feat: add openedx organization in fixtures and improve the format
BryanttV Sep 20, 2024
2d68332
test: add enrollment api integration tests
BryanttV Sep 20, 2024
c5c25c0
feat: add fixtures for course modes
BryanttV Sep 23, 2024
eb43544
test: add remaining integration tests
BryanttV Sep 23, 2024
5ec008a
chore: fix pylint errors
BryanttV Sep 23, 2024
041273a
fix: add missing ddt function in class decorator
BryanttV Sep 23, 2024
50a67dc
chore: move users data to fake_users file
BryanttV Sep 23, 2024
4cdee58
chore: remove utils folder
BryanttV Sep 23, 2024
cb0039b
docs: update methods docstring in the tests
BryanttV Sep 23, 2024
7b10550
feat: update matrix in integration tests workflow
BryanttV Sep 23, 2024
f8533d7
fix: use correct course_id
BryanttV Sep 24, 2024
9dbce66
fix: add organizations and course modes for course_id of quince
BryanttV Sep 24, 2024
2305410
chore: add test_enrollment_integration file
BryanttV Sep 24, 2024
486246b
chore: add missing letter
BryanttV Sep 26, 2024
843c9b1
refactor: include force field in ddt data when creating enrollment
BryanttV Sep 26, 2024
1e547be
test: add value for each param
BryanttV Sep 26, 2024
d6e84e2
docs: update docstring and name of methods
BryanttV Sep 26, 2024
31fada0
chore: add f flag to show a short test summary info
BryanttV Sep 26, 2024
a710bcc
refactor: create user in the setup method
BryanttV Sep 26, 2024
05a0e18
chore: remove old enrollments api integrations tests
BryanttV Sep 26, 2024
69692fa
test: check the applications state after each update
BryanttV Sep 27, 2024
658b2fb
chore: remove tutor command to import demo course in shell file
BryanttV Sep 27, 2024
8914e37
ci: update workflow to use new version of integration test in tutor a…
BryanttV Sep 27, 2024
a7bae95
chore: use demo_course_id variable name instead course_id
BryanttV Sep 27, 2024
6ba8bb0
chore: avoid extra changes in fixtures
BryanttV Sep 27, 2024
543ab51
Revert "chore: avoid extra changes in fixtures"
BryanttV Sep 27, 2024
cb6ce0b
chore: use a string instead of object in fixtures
BryanttV Sep 27, 2024
5a98fd8
ci: add tutor nightly in integration tests workflow
BryanttV Sep 27, 2024
88ee4f3
fix: fix typo
BryanttV Sep 27, 2024
c5607d3
chore: update dates in fixtures
BryanttV Sep 27, 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
8 changes: 7 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tutor_version: ['<18.0.0', '<19.0.0']
include:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BryanttV can we please explain why is this implementation necessary in the PR description? I think it's important to explain the reasoning behind this decision


Since I’m considering moving tutor local do importdemocourse to the GitHub Action, should we also pass the course ID to the environment in the step that runs the integration tests? This way, the action would handle the full demo course setup, and we can ensure that the tests always reference the correct course and prevent each plugin from setting it manually

I was able to obtain the course ID dynamically with:

COURSE_KEY=$(tutor local exec lms python manage.py lms shell -c "from openedx.core.djangoapps.content.course_overviews.models import CourseOverview; course = CourseOverview.objects.first(); print(course.id, end='')")

However, if the import process changes in future Open edX versions, this could break the tests. Of course, we could always introduce version-based logic to handle that, but we could also just set the course ID manually in the action (assuming the Demo course ID won’t change frequently). Starting from Tutor version 18.0.0, the ID is course-v1:OpenedX+DemoX+DemoCourse, so we’d handle logic for both IDs for now, and remove support for versions below 18.0.0 later

I’d like to hear your thoughts on this approach @BryanttV @mariajgrimaldi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like what you propose. I think it's more appropriate to leave that responsibility to the action, than to keep it in every plugin.

Copy link
Member

@mariajgrimaldi mariajgrimaldi Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely move this to the GH action itself.

I like the proposal's automatic approach to getting the course ID. However, I'm very wary of using code from the platform without any API or interface, even from the shell. I don't think it's worth it, considering the course ID hasn't changed much over time. The last change was very much needed: openedx/openedx-demo-course#50, it looks like it was very axim-specific for some reason.

- tutor_version: '<18.0.0'
course_id: 'course-v1:edX+DemoX+Demo_Course'
- tutor_version: '<19.0.0'
course_id: 'course-v1:OpenedX+DemoX+DemoCourse'
BryanttV marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Run Integration Tests
uses: eduNEXT/integration-test-in-tutor@mjh/run-integration-tests-outside-container
Expand All @@ -17,3 +21,5 @@ jobs:
openedx_extra_pip_requeriments: 'eox-tenant'
shell_file_to_run: 'scripts/execute_integration_tests.sh'
fixtures_file: 'fixtures/initial_data.json'
env:
COURSE_ID: ${{ matrix.course_id }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ python-quality-test:
run-tests: python-test python-quality-test

run-integration-tests: install-dev-dependencies
pytest ./eox_core --ignore-glob='**/unit/*' --ignore-glob='**/edxapp_wrapper/*'
pytest -rPf ./eox_core --ignore-glob='**/unit/*' --ignore-glob='**/edxapp_wrapper/*'

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
Expand Down
52 changes: 52 additions & 0 deletions eox_core/api/v1/tests/integration/data/fake_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,5 +626,57 @@
"city": "Charleston",
"goals": "Aenean vulputate eleifend tellus.",
},
{
"username": "gwalker33",
"email": "[email protected]",
"fullname": "Gary Walker",
"password": "zP7%1Yt!dB@",
"activate_user": True,
"mailing_address": "321 Birch Road",
"year_of_birth": 1996,
"gender": "m",
"level_of_education": "hs",
"city": "Sacramento",
"goals": "Praesent vestibulum dapibus nibh.",
},
{
"username": "tturner34",
"email": "[email protected]",
"fullname": "Tina Turner",
"password": "wJ4@5Lm!tQ#",
"activate_user": False,
"mailing_address": "753 Pine Street",
"year_of_birth": 1988,
"gender": "f",
"level_of_education": "m",
"city": "Portland",
"goals": "Duis lobortis massa nec est.",
},
{
"username": "jwhite35",
"email": "[email protected]",
"fullname": "Jack White",
"password": "qB2%9Cv!xF@",
"activate_user": True,
"mailing_address": "159 Spruce Lane",
"year_of_birth": 1995,
"gender": "m",
"level_of_education": "hs",
"city": "New Orleans",
"goals": "Vestibulum volutpat pretium libero.",
},
{
"username": "gwalker33",
"email": "[email protected]",
"fullname": "Gary Walker",
"password": "zP7%1Yt!dB@",
"activate_user": True,
"mailing_address": "321 Birch Road",
"year_of_birth": 1996,
"gender": "m",
"level_of_education": "hs",
"city": "Sacramento",
"goals": "Praesent vestibulum dapibus nibh.",
},
]
)
Loading
Loading