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

fix flaky test ordering #2427

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
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: 5 additions & 3 deletions ecommerce/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,13 @@ def test_product_managers():
"""Test that the default manager returns only active products and the 'all_objects' manager returns all the
products
"""
in_active_products = ProductFactory.create_batch(3, is_active=False)
inactive_products = ProductFactory.create_batch(3, is_active=False)
active_products = ProductFactory.create_batch(2, is_active=True)

assert list(Product.objects.all()) == active_products
assert list(Product.all_objects.all()) == in_active_products + active_products
assert list(Product.objects.all().order_by("id")) == list(active_products)
assert list(Product.all_objects.all().order_by("id")) == list(
inactive_products + active_products
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This works but I think if we are ordering the Product.objects.all().order_by("id") then the list makes sense. Take it or leave it

assert list(Product.objects.all().order_by("id")) == list(active_products)
assert list(Product.all_objects.all().order_by("id")) == list(
      inactive_products + active_products
 )



def test_product_multiple_active_for_single_purchasable_object():
Expand Down
Loading