def test_GetAirlines(self): airport = Airport(name="sc", x=4, y=20) def my_filter(*args, **kwargs): return [Airline(name="west"), Airline(name="east")] with patch.object(Airline.objects, 'filter', side_effect=my_filter) as mock_method: self.assertEqual(len(airport.getAirlines()), 2)
def test_gateDelete(self): c = Client() global user air = Airport(name='sc', x=0, y=0) response = c.post( '/ATC/gate/new', { 'identifier': 'gate1', 'size': 's', 'airport': str(air.id), 'user': str(user.id) }) self.assertEqual(response.status_code, 302) response = c.post('/ATC/gate/delete', { 'identifier': 'gate1', 'id': str(air.id), 'user': str(user.id) }) self.assertEqual(response.status_code, 302) response = c.post('/ATC/gate/new', { 'identifier': 'sc', 'x': '100', 'y': '100', 'user': str(user.id) }) self.assertGreater(response.status_code, 302) Gate.objects.filter(identifier="GateAgent").delete() Airport.objects.filter(identifier="sc").delete()
def test_gatecreate(self): global user c = Client() # instantiate the Django test client response = c.get('/ATC/new') self.assertEqual(response.status_code, 200) air = Airport(name='sc', x=0, y=0) response = c.post( '/ATC/gate/new', { 'identifier': 'gate1', 'size': 's', 'airport': str(air.id), 'user': str(user.id) }) self.assertEqual(response.status_code, 302) response = c.post( '/ATC/gate/new', { 'identifier': 'gate1', 'size': 's', 'airport': str(air.id), 'user': str(user.id) }) self.assertGreater(response.status_code, 399) Gate.objects.filter(identifier="gate1").delete() Airport.objects.filter(identifier="sc").delete()
def test_assert(self): plane = Plane(identifier="Airplane 1", size="l", currentPassengerCount=174, maxPassengerCount=200, runway=Runway(identifier="C1", size="m", airport=Airport(name="GSA", x=45, y=3))) self.assertEqual(plane.getRunway().identifier, "C1")
def test_assert(self): plane = Plane(identifier="Airplane 1", size="l", currentPassengerCount=174, maxPassengerCount=200, gate=Gate(identifier="A1", size="l", airport=Airport(name="GSA", x=45, y=3))) self.assertEqual(plane.getGate().identifier, "A1")
def test_GetRunways(self): airport = Airport(name="sc", x=4, y=20) r1 = Runway(identifier="west", size="s", airport=airport) r2 = Runway(identifier="east", size="m", airport=Airport(name="notsc", x=4, y=20)) r3 = Runway(identifier="south", size="l", airport=airport) all_runways = [r1, r2, r3] def my_filter(*args, **kwargs): return [x for x in all_runways if x.airport == kwargs["airport"]] with patch.object(Runway.objects, 'filter', side_effect=my_filter) as mock_method: self.assertEqual(len(airport.getRunways()), 2) all_runways[1].airport = airport self.assertEqual(len(airport.getRunways()), 3)
def test_GetGates(self): airport = Airport(name="sc", x=4, y=20) g1 = Gate(identifier="west", size="s", airport=airport) g2 = Gate(identifier="east", size="m", airport=Airport(name="notsc", x=4, y=20)) g3 = Gate(identifier="south", size="l", airport=airport) all_gates = [g1, g2, g3] def my_filter(*args, **kwargs): return [x for x in all_gates if x.airport == kwargs["airport"]] with patch.object(Gate.objects, 'filter', side_effect=my_filter) as mock_method: self.assertEqual(len(airport.getGate()), 2) all_gates[1].airport = airport self.assertEqual(len(airport.getGate()), 3)
def test_assert(self): gate = Gate(identifier="small gate", size="small", airport=Airport(name="big airport")) self.assertEqual(gate.getAirport().name, "big airport")