Skip to content

Commit

Permalink
Add measure products to DB seed data
Browse files Browse the repository at this point in the history
  • Loading branch information
pylipp committed Oct 1, 2024
1 parent 48a0b23 commit 706c79a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions back/boxtribute_server/cron/data_faking.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ def _generate_products(self):
15: ["Inhalation device"],
}
baby_products = ["Shirts", "Jackets", "Trousers"] # category 8
mass_measure_products = ["Rice", "Pasta", "Chickpeas", "Sugar", "Cereal"]
volume_measure_products = ["Sauce", "Milk", "Vegetable oil"]
size_ranges = {
"Underwear": 6, # Mixed sizes
"Tights": 6,
Expand Down Expand Up @@ -581,6 +583,20 @@ def _generate_products(self):
)
enabled_standard_products[b].append(product)

for names, size_range_id in zip(
[mass_measure_products, volume_measure_products], [28, 29]
):
for name in names:
product = create_custom_product(
category_id=11,
size_range_id=size_range_id,
gender=ProductGender.none,
base_id=b,
name=name,
price=self.fake.random_int(max=100),
user_id=self._user_id(b),
)
self.products[b].append(product)
# Delete a product
to_be_deleted_product = create_custom_product(
category_id=12,
Expand Down
2 changes: 1 addition & 1 deletion back/test/auth0_integration_tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _assert_successful_request(*args, **kwargs):
response = _assert_successful_request(auth0_client, query, field=resource)
assert len(response) == count

for resource, count in zip(["beneficiaries", "products"], [469, 312]):
for resource, count in zip(["beneficiaries", "products"], [469, 344]):
query = f"query {{ {resource} {{ totalCount }} }}"
response = _assert_successful_request(auth0_client, query, field=resource)
assert response["totalCount"] == count
Expand Down
2 changes: 1 addition & 1 deletion back/test/endpoint_tests/test_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_reseed_db(cron_client, monkeypatch, mocker):

query = "query { products { totalCount } }"
response = assert_successful_request(cron_client, query)
assert response["totalCount"] == 8 + 76 * 4 # minimal seed + generated
assert response["totalCount"] == 8 + 84 * 4 # minimal seed + generated

query = "query { transferAgreements { id } }"
response = assert_successful_request(cron_client, query)
Expand Down

0 comments on commit 706c79a

Please sign in to comment.