1
+ from cars import (get_all_jeeps , get_first_model_each_manufacturer ,
2
+ get_all_matching_models , sort_car_models )
3
+
4
+
5
+ def test_get_all_jeeps ():
6
+ expected = 'Grand Cherokee, Cherokee, Trailhawk, Trackhawk'
7
+ actual = get_all_jeeps ()
8
+ assert type (actual ) == str
9
+ assert actual == expected
10
+
11
+
12
+ def test_get_first_model_each_manufacturer ():
13
+ actual = get_first_model_each_manufacturer ()
14
+ expected = ['Falcon' , 'Commodore' , 'Maxima' , 'Civic' , 'Grand Cherokee' ]
15
+ assert actual == expected
16
+
17
+
18
+ def test_get_all_matching_models_default_grep ():
19
+ expected = ['Trailblazer' , 'Trailhawk' ]
20
+ assert get_all_matching_models () == expected
21
+
22
+
23
+ def test_get_all_matching_models_different_grep ():
24
+ expected = ['Accord' , 'Commodore' , 'Falcon' ]
25
+ assert get_all_matching_models (grep = 'CO' ) == expected
26
+
27
+
28
+ def test_sort_dict_alphabetically ():
29
+ actual = sort_car_models ()
30
+ # Order of keys should not matter, two dicts are equal if they have the
31
+ # same keys and the same values.
32
+ # The car models (values) need to be sorted here though
33
+ expected = {
34
+ 'Ford' : ['Fairlane' , 'Falcon' , 'Festiva' , 'Focus' ],
35
+ 'Holden' : ['Barina' , 'Captiva' , 'Commodore' , 'Trailblazer' ],
36
+ 'Honda' : ['Accord' , 'Civic' , 'Jazz' , 'Odyssey' ],
37
+ 'Jeep' : ['Cherokee' , 'Grand Cherokee' , 'Trackhawk' , 'Trailhawk' ],
38
+ 'Nissan' : ['350Z' , 'Maxima' , 'Navara' , 'Pulsar' ],
39
+ }
40
+ assert actual == expected
0 commit comments