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(emeritus_api): add more tests for emeritus API ingestion #3032

Merged
merged 11 commits into from
Aug 8, 2024

Conversation

asadali145
Copy link
Contributor

@asadali145 asadali145 commented Jul 1, 2024

What are the relevant tickets?

#3028

Description (What does it do?)

Adds more tests for the external course sync to make it more robust. Also, makes some refactoring to show filtered stats and make the object creation more consistent.

How can this be tested?

  • Checks should pass
  • Verify that all tests mentioned in the related issue are added.
  • Verify that it covers the edge cases around draft and live states of Certificate pages and Course Pages.
  • Verify that the stats logged by the command ./manage.py sync_external_course_runs --vendor emeritus are cleaner and much more accurate.
  • Test the ExternalCoursePage and CertificatePage states. Command should not update the status while updating the data.
    • Run the command on master.
    • Make a few changes in a live course and save as draft, this state is called live + draft
    • Unpublish a live course.
    • Make changes to a live course and publish it.
    • Run the command on this branch and it should update the data but not the status.
  • Test the above cases for the CertificatePage.

@asadali145
Copy link
Contributor Author

Waiting for #3048 as both have common tests.

@asadali145 asadali145 force-pushed the asad/more-tests-external-api-ingestion branch from b9801a1 to 0433b93 Compare August 5, 2024 10:32
Copy link
Contributor

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

Requested a couple of changes and the draft revision thing we discussed over call.

Comment on lines 44 to 48
self.stdout.write(
self.style.SUCCESS(
f"External course sync successful for {vendor_name}."
)
)
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 log this stat as part of log_stats?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not related to the stats, this is more of a success log. Kept it here intentionally. Do you think we should move this?

Comment on lines 516 to 520
if is_updated:
is_draft = course_page.has_unpublished_changes
revision = latest_revision.save_revision()
if not is_draft:
revision.publish()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also move this into a small method and call it from everywhere we need to run this logic?

@@ -136,6 +166,11 @@ def test_create_or_update_emeritus_course_page(
course_index_page = CourseIndexPageFactory.create(parent=home_page, title="Courses")
course = CourseFactory.create(is_external=True)

if test_image_name_without_extension:
emeritus_course_data["image_name"] = emeritus_course_data["image_name"].split(
Copy link
Contributor

Choose a reason for hiding this comment

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

While reviewing this test, We can improve the logic around matching the image name during sync. e.g. imagine an image name with two or three dots in it e.g. EMERITUS_COURSE.1.png out command would not handle this situation. So, we should split and remove only the last .<ext> part of an image name.

Copy link
Contributor

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

👍

@asadali145 asadali145 merged commit 23e7e54 into master Aug 8, 2024
7 checks passed
@asadali145 asadali145 deleted the asad/more-tests-external-api-ingestion branch August 8, 2024 13:07
This was referenced Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants