This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdegrees_test.py
68 lines (46 loc) · 1.95 KB
/
degrees_test.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
"""
Acceptance tests for degrees.py
Make sure that this file is in the same directory as degrees.py!
'Why do we fall sir? So that we can learn to pick ourselves up.'
- Batman Begins (2005)
"""
from degrees import load_data, person_id_for_name, shortest_path
load_data("large")
# Most test cases provided by Ken Walker. Thank you!
# source: https://edstem.org/us/courses/176/discussion/226814?answer=546980
def test0():
source = person_id_for_name("Jennifer Lawrence")
target = person_id_for_name("Tom Hanks")
assert len(shortest_path(source, target)) == 2
def test1():
source = person_id_for_name("Emma Watson")
target = person_id_for_name("Jennifer Lawrence")
assert len(shortest_path(source, target)) == 3
def test_zero_degree():
source = person_id_for_name("Tim Zinnemann")
target = person_id_for_name("Lahcen Zinoun")
assert shortest_path(source, target) is None
def test_one_degree():
source = person_id_for_name("Tom Cruise")
target = person_id_for_name("Lea Thompson")
assert len(shortest_path(source, target)) == 1
def test_two_degree():
source = person_id_for_name("Tom Cruise")
target = person_id_for_name("Tom Hanks")
assert len(shortest_path(source, target)) == 2
def test_three_degree():
source = person_id_for_name("Emma Watson")
target = person_id_for_name("Jennifer Lawrence")
assert len(shortest_path(source, target)) == 3
def test_four_degree():
source = person_id_for_name("Fred Astaire")
target = person_id_for_name("Mohamed Zinet")
assert len(shortest_path(source, target)) == 4
def test_six_degree():
source = person_id_for_name("Juliane Banse")
target = person_id_for_name("Bruce Davison")
assert len(shortest_path(source, target)) == 6
def test_eight_degree():
source = person_id_for_name("Juliane Banse")
target = person_id_for_name("Julian Acosta")
assert len(shortest_path(source, target)) == 8