def test_get_venue(self, client): venue = offerer_factories.VenueFactory(isPermanent=True) response = client.get(f"/native/v1/venue/{venue.id}") assert response.status_code == 200 assert response.json == { "id": venue.id, "name": venue.name, "latitude": float(venue.latitude), "longitude": float(venue.longitude), "city": venue.city, "publicName": venue.publicName, "isVirtual": venue.isVirtual, "isPermanent": venue.isPermanent, "withdrawalDetails": venue.withdrawalDetails, "address": venue.address, "postalCode": venue.postalCode, "venueTypeCode": venue.venueTypeCode.name, "description": venue.description, "contact": { "email": venue.contact.email, "phoneNumber": venue.contact.phone_number, "website": venue.contact.website, "socialMedias": venue.contact.social_medias, }, "accessibility": { "audioDisability": venue.audioDisabilityCompliant, "mentalDisability": venue.mentalDisabilityCompliant, "motorDisability": venue.motorDisabilityCompliant, "visualDisability": venue.visualDisabilityCompliant, }, }
def test_managed_venues_are_reindexed( self, mocked_async_index_offers_of_venue_ids): # Given applicant = users_factories.UserFactory() user_offerer = offers_factories.UserOffererFactory( user=applicant, offerer__validationToken="TOKEN") venue_1 = offerers_factories.VenueFactory( managingOfferer=user_offerer.offerer) venue_2 = offerers_factories.VenueFactory( managingOfferer=user_offerer.offerer) # When offerers_api.validate_offerer(user_offerer.offerer.validationToken) # Then mocked_async_index_offers_of_venue_ids.assert_called_once() called_args, _ = mocked_async_index_offers_of_venue_ids.call_args assert set(called_args[0]) == {venue_1.id, venue_2.id}
def test_venue_indexation_cycle(app): venue = offerers_factories.VenueFactory(isPermanent=True) assert search_testing.search_store["venues"] == {} search.async_index_venue_ids([venue.id]) assert search_testing.search_store["venues"] == {} search.index_venues_in_queue() assert venue.id in search_testing.search_store["venues"]
def test_return_venue_without_publicName_of_given_siret(self, app): # Given requested_venue = offerers_factories.VenueFactory(publicName=None) offerers_factories.VenueFactory() valid_encoded_token = self._create_adage_valid_token() test_client = TestClient(app.test_client()) test_client.auth_header = { "Authorization": f"Bearer {valid_encoded_token}" } # When response = test_client.get( f"/adage-iframe/venues/{requested_venue.siret}") # Then assert response.status_code == 200 assert response.json == { "id": requested_venue.id, "name": requested_venue.name, "publicName": None, }
def test_return_error_if_venue_does_not_exist(self, app): # Given offerers_factories.VenueFactory() valid_encoded_token = self._create_adage_valid_token() test_client = TestClient(app.test_client()) test_client.auth_header = { "Authorization": f"Bearer {valid_encoded_token}" } # When response = test_client.get("/adage-iframe/venues/123456789") # Then assert response.status_code == 404 assert response.json == {"siret": "Aucun lieu n'existe pour ce siret"}
def test_serialize_venue(): venue = offerers_factories.VenueFactory( venueTypeCode="VISUAL_ARTS", audioDisabilityCompliant=True, contact__email="*****@*****.**", contact__website="http://venue.example.com", contact__phone_number="+33.123456", contact__social_medias={ "facebook": None, "instagram": None, "snapchat": None, "twitter": "https://twitter.com/my.venue", }, ) serialized = AlgoliaBackend().serialize_venue(venue) assert serialized == { "objectID": venue.id, "city": venue.city, "name": venue.name, "offerer_name": venue.managingOfferer.name, "venue_type": venue.venueTypeCode.name, "description": venue.description, "audio_disability": True, "mental_disability": False, "motor_disability": False, "visual_disability": False, "email": "*****@*****.**", "phone_number": "+33.123456", "website": "http://venue.example.com", "facebook": None, "instagram": None, "snapchat": None, "twitter": "https://twitter.com/my.venue", "_geoloc": { "lng": float(venue.longitude), "lat": float(venue.latitude) }, }
def test_get_non_permanent_venue(self, client): venue = offerer_factories.VenueFactory(isPermanent=False) response = client.get(f"/native/v1/venue/{venue.id}") assert response.status_code == 404