Ejemplo n.º 1
0
    def test_pois_with_stands_on_all_pois(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region('pois', display=False)

            pois = get_not_null(r, 'pois')
            assert {p['id'] for p in pois} == {
                'poi:station_1',
                'poi:station_2',
                'poi:parking_1',
                'poi:parking_2',
            }
            for p in pois:
                is_valid_poi(p)
                if p['id'] == 'poi:station_1' or p['id'] == 'poi:station_2':
                    assert 'stands' in p
                    stands = p['stands']
                    if p['id'] == 'poi:station_1':
                        assert stands['available_places'] == 13
                        assert stands['available_bikes'] == 3
                        assert stands['total_stands'] == 16
                        assert stands['status'] == 'open'
                    elif p['id'] == 'poi:station_2':
                        assert stands['available_places'] == 99
                        assert stands['available_bikes'] == 98
                        assert stands['total_stands'] == 197
                        assert stands['status'] == 'open'
                else:
                    assert not 'stands' in p
Ejemplo n.º 2
0
    def test_pois_with_stands_on_second_places_nearby(self):
        with mock_bss_providers(pois_supported=['poi:station_1']):
            r = self.query_region('places/admin:74435/places_nearby?count=20', display=False)

            places_nearby = get_not_null(r, 'places_nearby')
            assert {p[p['embedded_type']]['id'] for p in places_nearby} == {
                'poi:parking_1',
                'poi:station_1',
                'stop_point:stopB',
                'stopB',
                'poi:station_2',
                'poi:parking_2',
                'stopC',
                'stop_point:stopC',
                'stopA',
                'stop_point:stopA',
                'stop_point:uselessA',
            }
            for p in places_nearby:
                embedded_type = p['embedded_type']
                if embedded_type == 'poi':
                    is_valid_poi(p[embedded_type])
                    if p[embedded_type]['id'] == 'poi:station_1':
                        assert 'stands' in p[embedded_type]
                        stands = p[embedded_type]['stands']
                        assert stands['available_places'] == 13
                        assert stands['available_bikes'] == 3
                        assert stands['total_stands'] == 16
                        assert stands['status'] == 'open'
                    else:
                        assert not 'stands' in p[embedded_type]
                else:
                    assert not 'stands' in p[embedded_type]
Ejemplo n.º 3
0
    def test_pois_places_nearby_depth_zero(self):
        """
        with depth=0 we don't have to poi_type, so it's not possible to use bss availability
        we don't want jormungandr to crash in this case
        """
        with mock_bss_providers(pois_supported=['station_1']):
            r = self.query_region(
                'places/admin:74435/places_nearby?depth=0&count=20',
                display=False)

            places_nearby = get_not_null(r, 'places_nearby')
            assert {p[p['embedded_type']]['id']
                    for p in places_nearby} == {
                        'poi:parking_1',
                        'poi:station_1',
                        'stop_point:stopB',
                        'stopB',
                        'poi:station_2',
                        'poi:parking_2',
                        'stopC',
                        'stop_point:stopC',
                        'stopA',
                        'stop_point:stopA',
                        'stop_point:uselessA',
                    }
Ejemplo n.º 4
0
    def test_pois_without_stands_on_places_nearby(self):
        with mock_bss_providers(pois_supported=['station_unknown']):
            r = self.query_region("places/admin:74435/places_nearby?count=20",
                                  display=False)

            places_nearby = get_not_null(r, 'places_nearby')
            assert {p[p['embedded_type']]['id']
                    for p in places_nearby} == {
                        'poi:parking_1',
                        'poi:station_1',
                        'stop_point:stopB',
                        'stopB',
                        'poi:station_2',
                        'poi:parking_2',
                        'stopC',
                        'stop_point:stopC',
                        'stopA',
                        'stop_point:stopA',
                        'stop_point:uselessA',
                    }
            for p in places_nearby:
                embedded_type = p['embedded_type']
                if embedded_type == 'poi':
                    is_valid_poi(p[embedded_type])
                assert not 'stands' in p[embedded_type]
Ejemplo n.º 5
0
    def test_pois_without_stands_on_places_autocompletion(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region("places/?q=first station&count=1", display=False)

            places = get_not_null(r, 'places')
            assert {p[p['embedded_type']]['id'] for p in places} == {'poi:station_1'}

            poi = places[0]['poi']
            is_valid_poi(poi)
            assert not 'stands' in poi
Ejemplo n.º 6
0
    def test_pois_with_stands_on_first_parking_place(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region("places/poi:parking_1", display=False)

            places = get_not_null(r, 'places')
            assert {p[p['embedded_type']]['id'] for p in places} == {'poi:parking_1'}

            poi = places[0]['poi']
            is_valid_poi(poi)
            assert not 'stands' in poi
Ejemplo n.º 7
0
    def test_pois_with_stands_on_first_parking_poi(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region("pois/poi:parking_1", display=False)

            pois = get_not_null(r, 'pois')
            assert {p['id'] for p in pois} == {'poi:parking_1'}

            poi = pois[0]
            is_valid_poi(poi)
            assert not 'stands' in poi
Ejemplo n.º 8
0
    def test_pois_without_stands_on_pois(self):
        with mock_bss_providers(pois_supported=['station_unknown']):
            r = self.query_region('pois', display=False)

            pois = get_not_null(r, 'pois')
            assert {p['id'] for p in pois} == {
                'poi:station_1',
                'poi:station_2',
                'poi:parking_1',
                'poi:parking_2',
            }
            for p in pois:
                is_valid_poi(p)
                assert not 'stands' in p
Ejemplo n.º 9
0
    def test_pois_with_stands_on_second_place(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region("places/poi:station_2", display=False)

            places = get_not_null(r, 'places')
            assert {p[p['embedded_type']]['id'] for p in places} == {'poi:station_2'}

            poi = places[0]['poi']
            is_valid_poi(poi)
            assert 'stands' in poi
            stands = poi['stands']
            assert stands['available_places'] == 99
            assert stands['available_bikes'] == 98
            assert stands['total_stands'] == 197
            assert stands['status'] == 'open'
Ejemplo n.º 10
0
    def test_pois_with_stands_on_first_poi(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region("pois/poi:station_1", display=False)

            pois = get_not_null(r, 'pois')
            assert {p['id'] for p in pois} == {'poi:station_1'}

            poi = pois[0]
            is_valid_poi(poi)
            assert 'stands' in poi
            stands = poi['stands']
            assert stands['available_places'] == 13
            assert stands['available_bikes'] == 3
            assert stands['total_stands'] == 16
            assert stands['status'] == 'open'
Ejemplo n.º 11
0
    def test_bss_stands_on_journeys_disabled_by_default(self):
        supported_pois = ['poi:station_1', 'poi:station_2']
        with mock_bss_providers(pois_supported=supported_pois):
            query = journey_basic_query + "&first_section_mode=bss&last_section_mode=bss"
            response = self.query_region(query)
            self.is_valid_journey_response(response, query)
            journeys = get_not_null(response, 'journeys')
            for poi in get_from_to_pois_of_journeys(journeys):
                is_valid_poi(poi)
                assert 'stands' not in poi

            # since no stands have been added, we have not added the bss provider as a feed publisher
            # thus we only have the 'static' data feed publisher
            feeds = get_not_null(response, 'feed_publishers')
            assert len(feeds) == 1
            assert next(f for f in feeds if f['name'] == 'routing api data')
Ejemplo n.º 12
0
    def test_journey_sections_from_to_poi_with_stands(self):
        supported_pois = ['poi:station_1']
        with mock_bss_providers(pois_supported=supported_pois):
            query = (
                journey_basic_query +
                "&first_section_mode=bss&last_section_mode=bss&add_poi_infos[]=bss_stands"
            )
            response = self.query_region(query)
            self.is_valid_journey_response(response, query)
            journeys = get_not_null(response, 'journeys')

            for poi in get_from_to_pois_of_journeys(journeys):
                is_valid_poi(poi)
                if poi['id'] in supported_pois:
                    assert 'stands' in poi
                    assert poi['stands']['available_places'] == 13
                    assert poi['stands']['available_bikes'] == 3
                    assert poi['stands']['total_stands'] == 16
                    assert poi['stands']['status'] == 'open'
                else:
                    assert 'stands' not in poi

            # check the feed publishers
            # we have the feed publisher of the 'static' data
            feeds = get_not_null(response, 'feed_publishers')
            tc_data = next(f for f in feeds if f['name'] == 'routing api data')
            assert tc_data == {
                'id': 'builder',
                'name': 'routing api data',
                'license': 'ODBL',
                'url': 'www.canaltp.fr',
            }
            # we check that the feedpublisher of the bss provider has been added
            bss_provider = next(f for f in feeds
                                if f['name'] == 'mock bss provider')
            assert bss_provider == {
                'id': 'mock_bss',
                'name': 'mock bss provider',
                'license': 'the death license',
                'url': 'bob.com',
            }
Ejemplo n.º 13
0
 def test_pois_with_stands_on_first_poi(self):
     with mock_bss_providers(pois_supported=[]):
         self._check_schema(
             '/v1/coverage/main_routing_test/pois/poi:station_1')