Exemple #1
0
def next_passage_for_missing_line_response_test(mock_missing_line_response):
    """
    test the whole next_passage_for_route_point
    mock the http call to return a response without wanted line  we should get no departure
    """
    cleverage = Cleverage(id='tata', timezone='UTC', service_url='http://bob.com/',
                          service_args={'a': 'bobette', 'b': '12'})

    mock_requests = MockRequests({
        'http://bob.com/stop_tutu':
            (mock_missing_line_response, 200)
    })

    route_point = MockRoutePoint(line_code='05', stop_id='stop_tutu')

    with mock.patch('requests.get', mock_requests.get):
        passages = cleverage.next_passage_for_route_point(route_point)

        assert passages is None
Exemple #2
0
def next_passage_for_route_point_local_timezone_test(mock_good_response):
    """
    test the whole next_passage_for_route_point
    mock the http call to return a good response, we should get some next_passages
    """
    cleverage = Cleverage(
        id='tata',
        timezone='Europe/Paris',
        service_url='http://bob.com/',
        service_args={
            'a': 'bobette',
            'b': '12'
        },
    )

    mock_requests = MockRequests(
        {'http://bob.com/stop_tutu': (mock_good_response, 200)})

    route_point = MockRoutePoint(line_code='05', stop_id='stop_tutu')

    with mock.patch('requests.get', mock_requests.get):
        passages = cleverage.next_passage_for_route_point(route_point)

        assert len(passages) == 2

        assert passages[0].datetime == datetime.datetime(2016,
                                                         4,
                                                         11,
                                                         12,
                                                         37,
                                                         15,
                                                         tzinfo=pytz.UTC)
        assert passages[0].is_real_time
        assert passages[1].datetime == datetime.datetime(2016,
                                                         4,
                                                         11,
                                                         12,
                                                         45,
                                                         35,
                                                         tzinfo=pytz.UTC)
        assert passages[1].is_real_time
Exemple #3
0
def next_passage_with_theoric_time_response_test(mock_theoric_response):
    """
    test the whole next_passage_for_route_point
    mock the http call to return a response with a theoric time we should get one departure
    """
    cleverage = Cleverage(id='tata',
                          timezone='UTC',
                          service_url='http://bob.com/',
                          service_args={
                              'a': 'bobette',
                              'b': '12'
                          })

    mock_requests = MockRequests(
        {'http://bob.com/stop_tutu': (mock_theoric_response, 200)})

    route_point = MockRoutePoint(line_code='05', stop_id='stop_tutu')

    with mock.patch('requests.get', mock_requests.get):
        passages = cleverage.next_passage_for_route_point(route_point)

        assert len(passages) == 2

        assert passages[0].datetime == datetime.datetime(2016,
                                                         4,
                                                         11,
                                                         14,
                                                         37,
                                                         15,
                                                         tzinfo=pytz.UTC)
        assert not passages[0].is_real_time
        assert passages[1].datetime == datetime.datetime(2016,
                                                         4,
                                                         11,
                                                         14,
                                                         45,
                                                         35,
                                                         tzinfo=pytz.UTC)
        assert passages[1].is_real_time