Skip to content

Commit

Permalink
(BSR)[API] refactor: remove unused variables from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnormant-pass committed Jan 27, 2025
1 parent 5d4d126 commit 3739383
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 34 deletions.
21 changes: 10 additions & 11 deletions api/tests/core/offers/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -2641,22 +2641,23 @@ def test_get_inactive_headline_offers_basic(self):

active_offer = factories.OfferFactory(isActive=True)
factories.StockFactory(offer=active_offer)
active_offer_headline_offer = factories.HeadlineOfferFactory(offer=active_offer, create_mediation=True)
# active offer headline offer:
factories.HeadlineOfferFactory(offer=active_offer, create_mediation=True)

finished_timespan = (
datetime.datetime.utcnow() - datetime.timedelta(days=20),
datetime.datetime.utcnow() - datetime.timedelta(days=10),
)
already_inactive_offer_headline_offer = factories.HeadlineOfferFactory(
offer=active_offer, timespan=finished_timespan, create_mediation=True
)
# alreeady inactive offer headline offer:
factories.HeadlineOfferFactory(offer=active_offer, timespan=finished_timespan, create_mediation=True)

another_active_offer = factories.OfferFactory(isActive=True)
timespan_finishing_in_the_future = (
datetime.datetime.utcnow() - datetime.timedelta(days=3),
datetime.datetime.utcnow() + datetime.timedelta(days=3),
)
soon_to_be_inactive_timespan = factories.HeadlineOfferFactory(
# soon to be inactive offer headline offer:
factories.HeadlineOfferFactory(
offer=another_active_offer, timespan=timespan_finishing_in_the_future, create_mediation=True
)

Expand All @@ -2679,9 +2680,8 @@ def test_get_inactive_headline_offers_should_not_return_already_deactivated_head
datetime.datetime.utcnow() - datetime.timedelta(days=20),
datetime.datetime.utcnow() - datetime.timedelta(days=10),
)
already_inactive_offer_headline_offer = factories.HeadlineOfferFactory(
offer=inactive_offer, timespan=finished_timespan, create_mediation=True
)
# already inactive headline offer
factories.HeadlineOfferFactory(offer=inactive_offer, timespan=finished_timespan, create_mediation=True)

another_inactive_offer = factories.OfferFactory(isActive=False)
timespan_finishing_in_the_future = (
Expand Down Expand Up @@ -2712,9 +2712,8 @@ def test_get_inactive_headline_offers_without_images(self):
datetime.datetime.utcnow() - datetime.timedelta(days=20),
datetime.datetime.utcnow() - datetime.timedelta(days=10),
)
already_inactive_headline_offer_without_mediation = factories.HeadlineOfferFactory(
offer=offer, timespan=finished_timespan, create_mediation=False
)
# already inactive headline offer without mediation
factories.HeadlineOfferFactory(offer=offer, timespan=finished_timespan, create_mediation=False)

headline_offer_query_result = repository.get_inactive_headline_offers()
assert headline_offer_query_result == [headline_offer_without_mediation]
2 changes: 1 addition & 1 deletion api/tests/core/subscription/ubble/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_applicant_creation_flow(self, requests_mock):
@pytest.mark.features(WIP_UBBLE_V2=True)
def test_applicant_creation_flow_updates_fraud_check(self, requests_mock):
user = users_factories.UserFactory()
fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
fraud_factories.BeneficiaryFraudCheckFactory(
type=fraud_models.FraudCheckType.UBBLE,
user=user,
thirdPartyId="",
Expand Down
4 changes: 3 additions & 1 deletion api/tests/local_providers/allocine_stocks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ def test_should_create_one_offer_with_movie_info(
allocine_stocks_provider.updateObjects()

# Then
created_offer = offers_models.Offer.query.one()
created_offer = offers_models.Offer.query.first()
created_stocks = offers_models.Stock.query.all()

assert created_offer, "No offer created"

for created_stock in created_stocks:
assert created_stock.price == decimal.Decimal("4.0")
assert created_stock.priceCategory.price == decimal.Decimal("4.0")
Expand Down
4 changes: 2 additions & 2 deletions api/tests/routes/backoffice/individual_bookings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def test_uncancel_booking_no_stock(self, authenticated_client, bookings):
def test_uncancel_and_mark_as_used_unlocks_achievement(self, authenticated_client, bookings):
festival_booking = bookings[1]

response = self.post_to_endpoint(authenticated_client, booking_id=festival_booking.id)
self.post_to_endpoint(authenticated_client, booking_id=festival_booking.id)

assert festival_booking.user.achievements

Expand Down Expand Up @@ -1216,7 +1216,7 @@ def test_batch_mark_as_used_bookings_with_multiple_errors(self, legit_user, auth
def test_batch_mark_as_used_unlocks_achievement(self, authenticated_client, bookings):
festival_booking = bookings[1]

response = self.post_to_endpoint(authenticated_client, form={"object_ids": str(festival_booking.id)})
self.post_to_endpoint(authenticated_client, form={"object_ids": str(festival_booking.id)})

assert festival_booking.user.achievements

Expand Down
12 changes: 6 additions & 6 deletions api/tests/routes/backoffice/offerers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def test_get_stats(self, authenticated_client, venue_factory, expected_revenue_t
venue=venue,
validation=offers_models.OfferValidationStatus.APPROVED.value,
)
booking = bookings_factories.BookingFactory(
bookings_factories.BookingFactory(
status=bookings_models.BookingStatus.USED,
quantity=1,
amount=10,
Expand Down Expand Up @@ -1239,39 +1239,39 @@ def test_action_name_depends_on_type(self, authenticated_client, offerer):
def test_get_full_sorted_history(self, authenticated_client, legit_user):
admin = users_factories.UserFactory()
user_offerer = offerers_factories.UserOffererFactory()
new_offerer_action = history_factories.ActionHistoryFactory(
history_factories.ActionHistoryFactory(
actionDate=datetime.datetime(2022, 10, 3, 13, 1),
actionType=history_models.ActionType.OFFERER_NEW,
authorUser=user_offerer.user,
user=user_offerer.user,
offerer=user_offerer.offerer,
comment=None,
)
pending_offerer_action = history_factories.ActionHistoryFactory(
history_factories.ActionHistoryFactory(
actionDate=datetime.datetime(2022, 10, 4, 14, 2),
actionType=history_models.ActionType.OFFERER_PENDING,
authorUser=admin,
user=user_offerer.user,
offerer=user_offerer.offerer,
comment="Documents complémentaires demandés",
)
comment_action = history_factories.ActionHistoryFactory(
history_factories.ActionHistoryFactory(
actionDate=datetime.datetime(2022, 10, 5, 15, 3),
actionType=history_models.ActionType.COMMENT,
authorUser=legit_user,
user=user_offerer.user,
offerer=user_offerer.offerer,
comment="Documents reçus",
)
validated_offerer_action = history_factories.ActionHistoryFactory(
history_factories.ActionHistoryFactory(
actionDate=datetime.datetime(2022, 10, 6, 16, 4),
actionType=history_models.ActionType.OFFERER_VALIDATED,
authorUser=admin,
user=user_offerer.user,
offerer=user_offerer.offerer,
comment=None,
)
other_comment_action = history_factories.ActionHistoryFactory(
history_factories.ActionHistoryFactory(
actionDate=datetime.datetime(2022, 10, 6, 17, 5),
actionType=history_models.ActionType.COMMENT,
authorUser=admin,
Expand Down
1 change: 0 additions & 1 deletion api/tests/routes/backoffice/venues_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,6 @@ def test_update_venue_with_address_manual_edition_clear_field_ban_id(
self, mock_get_municipality_centroid, authenticated_client
):
venue = offerers_factories.VenueFactory()
offerer_address_id = venue.offererAddressId
other_venue = offerers_factories.VenueFactory(
street="1 Rue Poivre",
postalCode="97400",
Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/external/user_subscription_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ class UbbleWebhookV2Test:
],
)
def test_ignore_events_before_identification_conclusion(self, ubble_client, status):
fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
fraud_factories.BeneficiaryFraudCheckFactory(
type=fraud_models.FraudCheckType.UBBLE,
thirdPartyId="idv_qwerty123",
status=fraud_models.FraudCheckStatus.STARTED,
Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/pro/delete_stock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def when_current_user_has_rights_on_offer_with_FF(self, client, db_session):
offerer=offer.venue.managingOfferer,
)
stock = offers_factories.StockFactory(offer=offer)
booking = BookingFactory(stock=stock)
BookingFactory(stock=stock)

# when
response = client.with_session_auth("pro@example.com").delete(f"/stocks/{stock.id}")
Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/pro/get_offerer_addresses_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_get_offerer_addresses_with_offers(self, client):
address__city="Paris",
address__banId="75107_7560_00001",
)
offer = offers_factories.OfferFactory(
offers_factories.OfferFactory(
venue__managingOfferer=offerer,
offererAddress=offerer_address_1,
venue__offererAddress=offerer_address_1,
Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/pro/get_product_by_ean_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_get_product_by_ean_empty_product_description(self, client):
offerer_id = offerer.id
offerers_factories.UserOffererFactory(user=user, offerer=offerer)
offerers_factories.VenueFactory(managingOfferer=offerer)
product = offers_factories.ProductFactory(
offers_factories.ProductFactory(
description=None,
name="Product name",
subcategoryId=subcategories_v2.LIVRE_PAPIER.id,
Expand Down
1 change: 0 additions & 1 deletion api/tests/routes/pro/patch_offer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ def test_user_can_link_offer_to_the_offerer_address_of_venue(self, get_address_m

assert response.status_code == 200
assert response.json["id"] == offer.id
updated_offer = Offer.query.get(offer.id)
assert offer.offererAddressId == venue.offererAddressId

@patch("pcapi.connectors.api_adresse.get_municipality_centroid")
Expand Down
7 changes: 1 addition & 6 deletions api/tests/routes/pro/patch_venue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ def test_update_venue_location_with_manual_edition_and_oa(self, client) -> None:
)

auth_request = client.with_session_auth(email=user_offerer.user.email)
venue_id = venue.id

venue_data = populate_missing_data_from_venue(
{
# Default data from api adresse TestingBackend
Expand Down Expand Up @@ -518,8 +516,6 @@ def test_update_should_be_able_to_update_venue_even_if_only_centroid_found(
street=None,
)
auth_request = client.with_session_auth(email=user_offerer.user.email)
venue_id = venue.id

venue_data = populate_missing_data_from_venue(
{
# Data sent by the frontend, originated from BAN autocomplete field
Expand Down Expand Up @@ -595,10 +591,9 @@ def test_should_not_create_oa_when_not_updating_location(self, client):
city="Lens",
managingOfferer=user_offerer.offerer,
)
offerer_address = venue.offererAddress
update_data = {"bookingEmail": "fakeemail@fake.com"}
auth_request = client.with_session_auth(email=user_offerer.user.email)
response = auth_request.patch("/venues/%s" % venue.id, json=update_data)
auth_request.patch("/venues/%s" % venue.id, json=update_data)

venue = offerers_models.Venue.query.one()
offerer_addresses = offerers_models.OffererAddress.query.order_by(offerers_models.OffererAddress.id).all()
Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/pro/post_stocks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def test_edit_one_event_stock_created_with_price_category(self, mocked_async_ind
],
}
with caplog.at_level(logging.INFO):
response = client.with_session_auth(user.email).post("/stocks/bulk/", json=stock_data)
client.with_session_auth(user.email).post("/stocks/bulk/", json=stock_data)

created_stock = Stock.query.first()
assert offer.id == created_stock.offerId
Expand Down

0 comments on commit 3739383

Please sign in to comment.