Skip to content

Commit

Permalink
Add/update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Dec 6, 2024
1 parent 335f849 commit 0724910
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions open_prices/prices/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ class Params:
)
location_osm_type = factory.fuzzy.FuzzyChoice(location_constants.OSM_TYPE_LIST)
date = date.fromisoformat("2023-10-30")
# owner = factory.Faker("user_name")
25 changes: 21 additions & 4 deletions open_prices/prices/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,14 @@ def test_price_proof_validation(self):
currency="EUR",
owner=user_session.user.user_id,
)
proof_2 = ProofFactory()
proof_gdpr = ProofFactory(
type=proof_constants.TYPE_GDPR_REQUEST,
location_osm_id=169450062,
location_osm_type=location_constants.OSM_TYPE_NODE,
date="2024-10-01",
currency="EUR",
)
proof_price_tag = ProofFactory(type=proof_constants.TYPE_PRICE_TAG)
# proof not set
PriceFactory(proof_id=None, owner=user_proof_receipt.owner)
# proof unknown
Expand All @@ -374,16 +381,26 @@ def test_price_proof_validation(self):
currency=user_proof_receipt.currency,
owner=user_proof_receipt.owner,
)
# different price & proof owner
# difference price and proof owner: raise a ValidationError
# if the proof type is different than PRICE_TAG
self.assertRaises(
ValidationError,
PriceFactory,
proof_id=proof_2.id, # different
proof_id=proof_gdpr.id, # gdpr proof
location_osm_id=proof_gdpr.location_osm_id,
location_osm_type=proof_gdpr.location_osm_type,
date=proof_gdpr.date,
currency=proof_gdpr.currency,
owner=user_proof_receipt.owner, # different owner
)
# different price & proof owner: ok for PRICE_TAG proofs
PriceFactory(
proof_id=proof_price_tag.id,
location_osm_id=user_proof_receipt.location_osm_id,
location_osm_type=user_proof_receipt.location_osm_type,
date=user_proof_receipt.date,
currency=user_proof_receipt.currency,
owner=user_proof_receipt.owner,
owner=user_proof_receipt.owner, # different owner
)
# proof location_osm_id & location_osm_type
self.assertRaises(
Expand Down
1 change: 1 addition & 0 deletions open_prices/proofs/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Meta:
# date = factory.Faker("date")
# currency = factory.Faker("currency_symbol")
# price_count = factory.LazyAttribute(lambda x: random.randrange(0, 100))
# owner = factory.Faker("user_name")


class ProofPredictionFactory(DjangoModelFactory):
Expand Down

0 comments on commit 0724910

Please sign in to comment.