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

test: add integration tests for the grade api AP-1406 #302

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jignaciopm
Copy link
Contributor

@jignaciopm jignaciopm commented Nov 7, 2024

Description

This PR adds integration tests for the Grade API and remove old module test integrations. These tests are executed in the job of Tutor Integration Tests

Testing instructions

Check the jobs of Tutor Integration Tests in the PR.

Jira Issue

Checklist for Merge

  • Tested in a remote environment
  • Updated documentation
  • Rebased master/main
  • Squashed commits

@jignaciopm jignaciopm requested a review from a team as a code owner November 7, 2024 03:26
@jignaciopm jignaciopm changed the title Jipm/ap 1406 test: add integration tests for the grade api AP-1406 Nov 7, 2024
eox_core/api/v1/tests/integration/test_views.py Outdated Show resolved Hide resolved
eox_core/api/v1/tests/integration/test_views.py Outdated Show resolved Hide resolved
Comment on lines +1625 to +1637
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn("earned_grade", response_content)
if extra_params["detailed"]:
self.assertIn("section_breakdown", response_content)
else:
self.assertNotIn("section_breakdown", response_content)

if extra_params["grading_policy"]:
self.assertIn("grading_policy", response_content)
self.assertIn("grader", response_content["grading_policy"])
self.assertIn("grade_cutoffs", response_content["grading_policy"])
else:
self.assertNotIn("grading_policy", response_content)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also check the content of the response, or is checking the existence of the keys enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to me that it is enough to check that the expected keys come. Evaluating whether the correct content is coming seems more related to unit tests in my opinion 🤔 what do you think? @mariajgrimaldi

Copy link
Contributor

Choose a reason for hiding this comment

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

Testing each API component's behavior is part of the unit test module, but here, we're testing that all those components work well together with the Open edX definitions available. So, we should include minimum checks for the response content to ensure the integration works as expected. Do you think that would work for this specific test suite?

eox_core/api/v1/tests/integration/test_views.py Outdated Show resolved Hide resolved
eox_core/api/v1/tests/integration/test_views.py Outdated Show resolved Hide resolved
eox_core/api/v1/tests/integration/test_views.py Outdated Show resolved Hide resolved
eox_core/api/v1/tests/integration/test_views.py Outdated Show resolved Hide resolved
@@ -1,429 +0,0 @@
Integration tests
Copy link
Contributor

Choose a reason for hiding this comment

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

If these integration tests were being executed somewhere (Jenkins?), dropping them would require a breaking change bump. I don't think it is, but we'll have to check either way.

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 agree with you, I didn't want to delete them either. How can we verify what you suggest? Because eliminating this module is part of the acceptance criteria for this task. @mariajgrimaldi 👀

Copy link
Contributor

Choose a reason for hiding this comment

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

The job executing this test was called Saas-PROD-QA-eox-core, and according to an internal spreadsheet, it was marked as to be deleted. Do you have access to our old Jenkins installation? If you do, could you check if it was deleted? In any case, I don't think this would merit a breaking change since the last time the job was successfully executed was 3 years ago.

@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tutor_version: ['<18.0.0', '<19.0.0', 'nightly']
tutor_version: ['<18.0.0', '<19.0.0']
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 think these changes should not reach main 👀

Copy link
Contributor

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

Thank you, @jignaciopm! I've added some additional comments for you to review. Please let me know once you do :)

"level_of_education": "p",
"city": "San Francisco",
"goals": "In ultrices sem nec turpis pretium, non consequat quam venenatis.",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this many new users?

Comment on lines +1625 to +1637
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn("earned_grade", response_content)
if extra_params["detailed"]:
self.assertIn("section_breakdown", response_content)
else:
self.assertNotIn("section_breakdown", response_content)

if extra_params["grading_policy"]:
self.assertIn("grading_policy", response_content)
self.assertIn("grader", response_content["grading_policy"])
self.assertIn("grade_cutoffs", response_content["grading_policy"])
else:
self.assertNotIn("grading_policy", response_content)
Copy link
Contributor

Choose a reason for hiding this comment

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

Testing each API component's behavior is part of the unit test module, but here, we're testing that all those components work well together with the Open edX definitions available. So, we should include minimum checks for the response content to ensure the integration works as expected. Do you think that would work for this specific test suite?


def test_get_grade_for_enrollment_not_found(self):
"""
Test grade info for a enrollment not found.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Test grade info for a enrollment not found.
Test grade info for a user not enrolled in the course.


def test_get_grade_for_course_not_found(self):
"""
Test grade info for a course not found.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Test grade info for a course not found.
Test grade info for an existing user in a course that does not exist.

response_data, [
"No course found for course_id `course-not-exist`"
],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if the user does not exist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants