|
| 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(): |
| 19 | + expected = ['Trailblazer', 'Trailhawk'] |
| 20 | + assert get_all_matching_models() == expected |
| 21 | + expected = ['Accord', 'Commodore', 'Falcon'] |
| 22 | + assert get_all_matching_models(grep='CO') == expected |
| 23 | + |
| 24 | + |
| 25 | +def test_sort_dict_alphabetically(): |
| 26 | + actual = sort_car_models() |
| 27 | + # Order of keys should not matter, two dicts are equal if they have the |
| 28 | + # same keys and the same values. |
| 29 | + # The car models (values) need to be sorted here though |
| 30 | + expected = { |
| 31 | + 'Ford': ['Fairlane', 'Falcon', 'Festiva', 'Focus'], |
| 32 | + 'Holden': ['Barina', 'Captiva', 'Commodore', 'Trailblazer'], |
| 33 | + 'Honda': ['Accord', 'Civic', 'Jazz', 'Odyssey'], |
| 34 | + 'Jeep': ['Cherokee', 'Grand Cherokee', 'Trackhawk', 'Trailhawk'], |
| 35 | + 'Nissan': ['350Z', 'Maxima', 'Navara', 'Pulsar'], |
| 36 | + } |
| 37 | + assert actual == expected |
0 commit comments