mitodl / mitxonline

BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

Fix flaky test: test_create_featured_courses #2216

Closed JenniWhitman closed 3 months ago

JenniWhitman commented 3 months ago

What are the relevant tickets?

Fixes https://github.com/mitodl/hq/issues/4308

Description (What does it do?)

test_create_featured_courses performs fine when the dates align, but when the factory produces a random date sometimes that date doesn't align as one would expect. To combat this, I set the dates based on one on another and based on "now" to keep the results consistent. This was already in place for the future courses since their dates determined their order, but I have also now done this for the in_progress course. I also made the check that they're all in place into one statement instead of 4 using sets.

How can this be tested?

Check my logic and run the test... a lot.