def test_proper_spot_count(self): new_level = Level('tests/test_non_consecutive.txt') large_spot_count, compact_spot_count, mc_spot_count = 0, 0, 0 while 1: key = new_level.park(TestLargeVehicle()) if not key: break large_spot_count += 1 while 1: key = new_level.park(Car('test car')) if not key: break compact_spot_count += 1 while 1: key = new_level.park(Motorcycle('test mc')) if not key: break mc_spot_count += 1 self.assertEqual(large_spot_count, 16) self.assertEqual(compact_spot_count, 13) self.assertEqual(mc_spot_count, 3)
def test_park_in_unparked_spot(self): new_level = Level('tests/test_consecutive.txt') for i in xrange(45): car_key = new_level.park(Car('test car')) while 1: key = new_level.park(Motorcycle('test mc')) if not key: break self.assertIsNone(new_level.park(Motorcycle('test mc'))) new_level.unpark(car_key) self.assertIsNotNone(new_level.park(Motorcycle('test mc')))
def test_can_fit_empty(self): large_spot = Spot(SpotSize.LARGE) compact_spot = Spot(SpotSize.COMPACT) mc_spot = Spot(SpotSize.MOTORCYCLE) self.assertTrue(large_spot.can_fit(Bus('test bus'))) self.assertFalse(compact_spot.can_fit(Bus('test bus'))) self.assertFalse(mc_spot.can_fit(Bus('test bus'))) self.assertTrue(large_spot.can_fit(Car('test car'))) self.assertTrue(compact_spot.can_fit(Car('test car'))) self.assertFalse(mc_spot.can_fit(Car('test car'))) self.assertTrue(large_spot.can_fit(Motorcycle('test mc'))) self.assertTrue(compact_spot.can_fit(Motorcycle('test mc'))) self.assertTrue(mc_spot.can_fit(Motorcycle('test mc')))
def test_park_full(self): new_level = Level('tests/test_non_consecutive.txt') while 1: key = new_level.park(Motorcycle('test mc')) if not key: break key = new_level.park(Car('test car')) self.assertIsNone(key)
def test_park_no_bigger_available(self): new_level = Level('tests/test_non_consecutive.txt') while 1: key = new_level.park(Car('test car')) if not key: break mc_spot_count = 0 while 1: key = new_level.park(Motorcycle('test mc')) if not key: break mc_spot_count += 1 self.assertEqual(mc_spot_count, 3)
if text == 'exit': break text = text.split(' ') if len(text) != 2: continue (command1, command2) = text if command1 == 'park': if command2 == 'car': vehicle = Car('test car') elif command2 == 'motorcycle': vehicle = Motorcycle('test motorcycle') elif command2 == 'bus': vehicle = Bus('test bus') else: continue key = garage.park(vehicle) if key is None: print 'There is no more room' else: print 'Your key: {}'.format(key) list_of_keys.append(key) elif command1 == 'unpark': vehicle = garage.unpark(command2)
from vehicle.car import Car from vehicle.motorcycle import Motorcycle # car = Car('BMW', 'Merah') motorcycle = Motorcycle('YAMAHA', 'Blue') print motorcycle.show_colors_provided()
def setUp(self): super(MotorcycleTest, self).setUp() self.test_mc = Motorcycle('test mc')