-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_functions.py
82 lines (64 loc) · 3.13 KB
/
test_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from db_objects import *
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from Functions import *
def pytest_funcarg__session(request):
db = create_engine('sqlite:///mbta.db', echo=False)
Base.metadata.create_all(db)
Session = sessionmaker(bind=db)
session = Session()
return session
def pytest_funcarg__triprecord(request, session):
record = session.query(TripRecord).first()
return record
def pair_equal(pair1, pair2):
if pair1 == pair2 or pair1 == pair2[::-1]:
return True
else:
return False
def test_find_segment_ALEWIFE(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.397805, -71.131591)),
('Alewife', 'Davis'))
def test_find_segment_ALEWIFE2(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.397969, -71.135044)),
('Alewife', 'Davis'))
def test_find_segment_DAVIS(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.392056, -71.119060)),
('Davis', 'Porter'))
def test_find_segment_PORTER(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.383352, -71.119532)),
('Porter', 'Harvard'))
def test_find_segment_HARVARD(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.368863, -71.110090)),
('Harvard', 'Central'))
def test_find_segment_CENTRAL(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.363198, -71.096354)),
('Central', 'Kendall/MIT'))
def test_find_segment_MIT(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.361715, -71.078269)),
('Kendall/MIT', 'Charles/MGH'))
def test_find_segment_MGH(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.359134, -71.067219)),
('Charles/MGH', 'Park Street'))
def test_find_segment_PARK(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.355893, -71.061459)),
('Park Street', 'Downtown Crossing'))
def test_find_segment_DOWNTOWN(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.353835, -71.057797)),
('Downtown Crossing', 'South Station'))
def test_find_segment_SOUTH(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.347594, -71.053991)),
('South Station', 'Broadway'))
def test_find_segment_BROADWAY(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.336328, -71.056950)),
('Broadway', 'Andrew'))
def test_find_segment_ANDREW(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.327684, -71.057934)),
('Andrew', 'JFK/Umass'))
def test_find_segment_JFK(session, triprecord):
assert pair_equal(find_segment(triprecord, session, (42.316547, -71.052152)),
('JFK/Umass', 'Savin Hill'))
def test_find_segment_BRAINTREEBRANCH(session, triprecord):
triprecord.trip_id = 3
assert pair_equal(find_segment(triprecord, session, (42.300707, -71.054977)),
('JFK/Umass', 'North Quincy'))