Example #1
0
    def pois_with_stands_on_all_places_nearby_test(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region('places/admin:74435/places_nearby', display=False)

            places_nearby = get_not_null(r, 'places_nearby')
            assert {p[p['embedded_type']]['id'] for p in places_nearby} == {'parking_1', 'station_1',
                                                                            'stop_point:stopB', 'stopB', 'station_2',
                                                                            'parking_2', 'stopC', 'stop_point:stopC',
                                                                            'stopA', 'stop_point:stopA'}
            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'] == 'station_1' or p[embedded_type]['id'] == 'station_2':
                        assert 'stands' in p[embedded_type]
                        stands = p[embedded_type]['stands']
                    if p[embedded_type]['id'] == 'station_1':
                        assert stands['available_places'] == 13
                        assert stands['available_bikes'] == 3
                        assert stands['total_stands'] == 16
                    elif p[embedded_type]['id'] == 'station_2':
                        assert stands['available_places'] == 99
                        assert stands['available_bikes'] == 98
                        assert stands['total_stands'] == 197
                    else:
                        assert not 'stands' in p[embedded_type]
                else:
                    assert not 'stands' in p[embedded_type]
Example #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]
    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]
Example #4
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
Example #5
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
Example #6
0
    def pois_without_stands_on_place_test(self):
        with mock_bss_providers(pois_supported=['station_unknown']):
            r = self.query_region("places/station_1", display=False)

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

            poi = places[0]['poi']
            is_valid_poi(poi)
            assert not 'stands' in poi
Example #7
0
 def test_bss_stands_on_journeys_disabled_by_default(self):
     supported_pois = ['station_1', '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
Example #8
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
Example #9
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
Example #10
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
Example #11
0
    def test_pois_without_stands_on_poi(self):
        with mock_bss_providers(pois_supported=['station_unknown']):
            r = self.query_region("pois/station_1", display=False)

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

            poi = pois[0]
            is_valid_poi(poi)
            assert not 'stands' in poi
Example #12
0
    def test_pois_with_stands_on_second_poi(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region("pois/station_2", display=False)

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

            poi = pois[0]
            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
Example #13
0
    def test_pois_with_stands_on_first_place(self):
        with mock_bss_providers(pois_supported=[]):
            r = self.query_region("places/poi:station_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 'stands' in poi
            stands = poi['stands']
            assert stands['available_places'] == 13
            assert stands['available_bikes'] == 3
            assert stands['total_stands'] == 16
Example #14
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')
Example #15
0
    def pois_with_stands_on_first_of_pois_test(self):
        with mock_bss_providers(pois_supported=['station_1']):
            r = self.query_region('pois', display=False)

            pois = get_not_null(r, 'pois')
            assert {p['id'] for p in pois} == {'station_1', 'station_2', 'parking_1', 'parking_2'}
            for p in pois:
                is_valid_poi(p)
                if p['id'] == 'station_1':
                    assert 'stands' in p
                    stands = p['stands']
                    assert stands['available_places'] == 13
                    assert stands['available_bikes'] == 3
                    assert stands['total_stands'] == 16
                else:
                    assert not 'stands' in p
Example #16
0
    def test_journey_sections_from_to_poi_with_stands(self):
        supported_pois = ['station_1']
        with mock_bss_providers(pois_supported=supported_pois):
            query = journey_basic_query + "&first_section_mode=bss&last_section_mode=bss&bss_stands=true"
            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
                else:
                    assert 'stands' not in poi
    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',
            }