Skip to content

Commit

Permalink
moer query checks
Browse files Browse the repository at this point in the history
  • Loading branch information
specialunderwear committed Apr 17, 2024
1 parent 3f7f03a commit 59c1683
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/reverse/test_reallifecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_mapping(self):
# Map the csv resources to product resources
product_resources = CSVProductMapping.apply(products)

with self.assertNumQueries(10):
with self.assertNumQueries(59 * 4 + 10):
# Map the product resources to products and save in DB
_, errors = products_to_db(product_resources)
self.assertEqual(len(errors), 0)
Expand All @@ -218,6 +218,22 @@ def test_mapping(self):
self.assertEqual(ProductAttributeValue.objects.all().count(), 257)
self.assertEqual(ProductImage.objects.all().count(), 52)


with open(csv_file) as f:
products_2 = csv_codec.reader(f, CSVProductResource, includes_header=True)

# The seocnd time, the querycount should be lower
product_resources_2 = CSVProductMapping.apply(products_2)

with self.assertNumQueries(59 + 10):
# Map the product resources to products and save in DB
_, errors = products_to_db(product_resources_2)
self.assertEqual(len(errors), 0)

self.assertEqual(Product.objects.all().count(), 59)
self.assertEqual(ProductAttributeValue.objects.all().count(), 257)
self.assertEqual(ProductImage.objects.all().count(), 52)

def get_csv_fixture(self, filename):
return path.realpath(
path.join(
Expand Down

0 comments on commit 59c1683

Please sign in to comment.