/
testUnitTests.py
99 lines (82 loc) · 4.03 KB
/
testUnitTests.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import unittest
from AirportAtlas import *
from GraphRouteConstructor import *
from Currency import *
from Itinerary import *
from AircraftTable import *
from main import check_file, check_format
class UnitTests(unittest.TestCase):
def test_whitespace_airport_atlas(self):
"""
Test to ensure AirportAtlas can handle input file with leading and/or trailing whitespace
"""
atlas=AirportAtlas('testFiles/test_airports_whitespace.csv')
self.assertTrue('DUB' in atlas.getAirports())
self.assertTrue(53.421333 == atlas.getAirport('DUB').getLat())
self.assertTrue(-6.270075 == atlas.getAirport('DUB').getLong())
self.assertTrue('Ireland' in atlas.getAirport('DUB').getCountry())
def test_check_file(self):
"""
Check if input is a valid directory/file
"""
self.assertFalse(check_file('madeup'))
self.assertTrue(check_file('testFiles/test_path_feasible_747.csv'))
def test_check_format(self):
"""
Test to check that the given itinerary file is in the correct format
"""
self.assertTrue(check_format('testFiles/test_path_feasible_747.csv'))
self.assertFalse(check_format('testFiles/test_airports.csv'))
def test_shortest_path_infeasible(self):
"""
Test that shortest path returns infeasible result for known infeasible journey
747 can not fly directly from Ireland to Australia so route in test_path.csv is infeasible
"""
itinerary = Itinerary('testFiles/test_path_infeasible_747.csv')
atlas = AirportAtlas('input/airport.csv')
aircraft_table = AircraftTable('input/aircraft.csv')
currency= Currency('input/countrycurrency.csv','input/currencyrates.csv')
graph=GraphRouteConstructor(itinerary.get_itinerary()[0],atlas,currency)
self.assertTrue(graph.shortest_path(aircraft_table.getAircraft('747'), atlas)=="This journey is infeasible for your aircraft")
def test_shortest_path_feasible(self):
"""
Test that shortest path returns infeasible result for known feasible journey
747 has range of 9,800 so route within Ireland like in test_path_feasible_747.csv is feasible
"""
itinerary = Itinerary('testFiles/test_path_feasible_747.csv')
atlas = AirportAtlas('input/airport.csv')
aircraft_table = AircraftTable('input/aircraft.csv')
currency= Currency('input/countrycurrency.csv','input/currencyrates.csv')
graph=GraphRouteConstructor(itinerary.get_itinerary()[0],atlas,currency)
self.assertTrue(graph.shortest_path(aircraft_table.getAircraft('747'), atlas)!="This journey is infeasible for your aircraft")
def test_cost_shortest_path(self):
"""
Test to check for value returned for simple shortest path cost
"""
itinerary = Itinerary('testFiles/test_path_cost_simple.csv')
atlas = AirportAtlas('input/airport.csv')
aircraft_table = AircraftTable('input/aircraft.csv')
currency= Currency('input/countrycurrency.csv','input/currencyrates.csv')
graph=GraphRouteConstructor(itinerary.get_itinerary()[0],atlas,currency)
cost=graph.shortest_path(aircraft_table.getAircraft('747'), atlas)[1]
#SNN to DUB, DUB to OSL, OSL to SNN
#194+1291+0.1155*1476=1655.48
self.assertTrue(cost==1655.48)
def test_whitespace_itinerary(self):
"""
Test to ensure Itinerary can handle input file with leading and/or trailing whitespace
Similar to AirportAtlas
"""
pass
def test_whitespace_currency(self):
"""
Test to ensure Currency can handle input file with leading and/or trailing whitespace
Similar to AirportAtlas
"""
pass
def test_whitespace_aircrafttable(self):
"""
Test to ensure AircraftTable can handle input file with leading and/or trailing whitespace
Similar to AirportAtlas
"""
pass