Ejemplo n.º 1
0
def test_bad_route(cli_runner):
    mock.reset()
    setup_routes_happy_path(mock)

    result = cli_runner(SCRIPT_NAME, '-d 20181007234100-05:00',
                        '-h ' + mock.pretend_url, '5 - Brooklyn Center',
                        'Brooklyn Center', 'south')

    result | should.have.key('returncode').that.should.equal(1)
    result | should.have.key('stderr')
    result['stderr'] | should.equal('ERROR: Route not found\n')
Ejemplo n.º 2
0
def test_route_endpoint_returns_non_200(cli_runner):
    mock.reset()
    mock.when('GET ' + ROUTE_PATH).reply(status=404, times=FOREVER)

    result = cli_runner(SCRIPT_NAME, '-d 20181007234100-05:00',
                        '-h ' + mock.pretend_url, '5 - Brooklyn Center',
                        'Brooklyn Center', 'south')

    result | should.have.key('returncode').that.should.equal(1)
    result | should.have.key('stderr')
    result['stderr'] | should.equal('ERROR: Route endpoint misbehaved\n')
Ejemplo n.º 3
0
def test_bad_stop(cli_runner):
    mock.reset()
    setup_routes_happy_path(mock)
    setup_directions_happy_path(mock, '5')
    setup_stops_happy_path(mock, '5', '1')

    result = cli_runner(SCRIPT_NAME, '-d 20181007234100-05:00',
                        '-h ' + mock.pretend_url, '5 - Brklyn Center',
                        'NON-EXISTANT', 'south')

    result | should.have.key('returncode').that.should.equal(1)
    result | should.have.key('stderr')
    result['stderr'] | should.equal('ERROR: Stop not found\n')
Ejemplo n.º 4
0
def test_multiple_directions(cli_runner):
    mock.reset()
    setup_routes_happy_path(mock)
    setup_directions_happy_path(mock, '5')

    result = cli_runner(SCRIPT_NAME, '-d 20181007234100-05:00',
                        '-h ' + mock.pretend_url, '5 - Brklyn Center',
                        'Brooklyn Center', 'bound')

    result | should.have.key('returncode').that.should.equal(1)
    result | should.have.key('stderr')
    result['stderr'] | should.equal(
        'ERROR: More than one Direction found. Please refine Direction\n')
Ejemplo n.º 5
0
def test_direction_endpoint_returns_non_200(cli_runner):
    mock.reset()
    setup_routes_happy_path(mock)
    mock.when('GET ' + DIR_PATH.format(route='5')).reply(status=404,
                                                         times=FOREVER)

    result = cli_runner(SCRIPT_NAME, '-d 20181007234100-05:00',
                        '-h ' + mock.pretend_url, '5 - Brklyn Center',
                        'Brooklyn Center', 'south')

    result | should.have.key('returncode').that.should.equal(1)
    result | should.have.key('stderr')
    result['stderr'] | should.equal('ERROR: Direction endpoint misbehaved\n')
Ejemplo n.º 6
0
def test_successful_lookup_later_stop(cli_runner):
    mock.reset()
    setup_routes_happy_path(mock)
    setup_directions_happy_path(mock, '5')
    setup_stops_happy_path(mock, '5', '1')
    setup_times_actual_false_happy_path(mock, '5', '1', '44FM')

    result = cli_runner(SCRIPT_NAME, '-d 1538969940000',
                        '-h ' + mock.pretend_url, '5 - Brklyn Center', '44th',
                        'south')

    print(result['stderr'])

    result | should.have.key('returncode').that.should.equal(0)
    result | should.have.key('stdout')
    result['stdout'] | should.equal('22 Min\n')
Ejemplo n.º 7
0
def test_successful_lookup(cli_runner):
    mock.reset()
    setup_routes_happy_path(mock)
    setup_directions_happy_path(mock, '5')
    setup_stops_happy_path(mock, '5', '1')
    setup_times_actual_true_happy_path(mock, '5', '1', 'BCTC')

    result = cli_runner(SCRIPT_NAME, '-d 20181007234100-05:00',
                        '-h ' + mock.pretend_url, '5 - Brklyn Center',
                        'Brooklyn Center', 'south')

    print(result['stderr'])

    result | should.have.key('returncode').that.should.equal(0)
    result | should.have.key('stdout')
    result['stdout'] | should.equal('16 Min\n')