Exemple #1
0
def make_url_date_and_count_test():
    synthese = Synthese(id='tata',
                        timezone='UTC',
                        service_url='http://bob.com/')

    url = synthese._make_url(
        MockRoutePoint(route_id='route_tata',
                       line_id='line_toto',
                       stop_id='stop_tutu'),
        count=2,
        from_dt=_timestamp("12:00"),
    )

    # it should be a valid url
    assert validators.url(url)

    assert url.startswith('http://bob.com/')
    assert 'SERVICE=tdg' in url
    assert 'roid=stop_tutu' in url
    # we should have the param we provided
    assert 'rn=2' in url
    assert 'date=2016-02-07 12:00' in url
Exemple #2
0
def next_passage_for_route_point_failure_test():
    """
    test the whole next_passage_for_route_point

    the timeo's response is in error (status = 404), we should get 'None'
    """
    synthese = Synthese(id='tata',
                        timezone='UTC',
                        service_url='http://bob.com/')

    mock_requests = MockRequests({
        'http://bob.com/?SERVICE=tdg&roid=stop_tutu':
        (mock_good_response(), 404)
    })

    route_point = MockRoutePoint(route_id='route_tata',
                                 line_id='line_toto',
                                 stop_id='stop_tutu')

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

        assert passages is None
Exemple #3
0
def status_test():
    synthese = Synthese(id=u'tata-é$~#@"*!\'`§èû',
                        timezone='UTC',
                        service_url='http://bob.com/')
    status = synthese.status()
    assert status['id'] == u"tata-é$~#@\"*!'`§èû"
def xml_invalid_test():
    builder = Synthese("id_synthese", "http://fake.url/", "Europe/Paris")
    xml = get_xml_parser().replace("</journey>", "", 1)
    with pytest.raises(et.ParseError):
        builder._get_synthese_passages(xml)
Exemple #5
0
def status_test():
    synthese = Synthese(id='tata', timezone='UTC', service_url='http://bob.com/')
    status = synthese.status()
    assert status['id'] == 'tata'
Exemple #6
0
def xml_date_time_invalid_test():
    builder = Synthese("id_synthese", "http://fake.url/", "Europe/Paris")
    xml = get_xml_parser().replace("2016-Mar-21 12:07:37",
                                   "2016-Mar-41 12:07:37", 1)
    builder._get_synthese_passages(xml)
def xml_date_time_invalid_test():
    builder = Synthese("id_synthese", "http://fake.url/", "Europe/Paris")
    xml = get_xml_parser().replace(str("2016-Mar-21 12:07:37"), str("2016-Mar-41 12:07:37"), 1)

    with pytest.raises(ValueError):
        builder._get_synthese_passages(xml)