def test_add_whenValid_shouldAddPassengerToPassengersList(self): train = Train('test name', 100) result = train.add('passenger test name') self.assertEqual(['passenger test name'], train.passengers) self.assertEqual('Added passenger passenger test name', result)
def test_remove_whenPassengerNonExistent_shouldRaise(self): train = Train('test name', 100) with self.assertRaises(ValueError) as context: train.remove('passenger test name') self.assertIsNotNone(context.exception)
def test_train_add__when_passenger_already_added__expect_ValueError(self): train = Train("Test", 10) passenger = "Pesho" with self.assertRaises(ValueError) as context: train.add(passenger) train.add(passenger) self.assertEqual("Passenger Pesho Exists", str(context.exception))
def test_add_whenNotEnoughCapacity_shouldRaise(self): train = Train('test name', 1) train.add('passenger test name') with self.assertRaises(ValueError) as context: train.add('passenger test name2') self.assertIsNotNone(context.exception)
def test_add_whenPassengerNameAlreadyExists_shouldRaise(self): train = Train('test name', 100) train.add('passenger test name') with self.assertRaises(ValueError) as context: train.add('passenger test name') self.assertIsNotNone(context.exception)
def test_remove_whenValid_shouldRemovePassenger(self): train = Train('test name', 100) train.add('passenger test name') result = train.remove('passenger test name') self.assertEqual([], train.passengers) self.assertEqual('Removed passenger test name', result)
def test_remove(self): test_train = Train('test', 3) test_train.add('test_person') test_train.add('test_person_two') expected = "Removed test_person" self.assertEqual(2, len(test_train.passengers)) actual = test_train.remove('test_person') self.assertEqual(1, len(test_train.passengers)) self.assertEqual(expected, actual)
def test_train_add__when_passenger_added_if_not_enough_capacity__expect_ValueError( self): train = Train("Test", 1) passenger = "Pesho" passenger2 = "Peter" with self.assertRaises(ValueError) as context: train.add(passenger) train.add(passenger2) self.assertEqual("Train is full", str(context.exception))
def setUp(self): self.train = Train("Orient", 50)
def test_remove__when_passenger_on_train_expect_to_be_removed(self): train = Train("Test", 10) passenger = "Pesho" train.add(passenger) self.assertEqual("Removed Pesho", train.remove(passenger))
def test_remove__when_passenger_not_on_train__expect_ValueError(self): train = Train("Test", 10) passenger = "Pesho" with self.assertRaises(ValueError) as context: train.remove(passenger) self.assertEqual("Passenger Not Found", str(context.exception))
def setUp(self): self.train = Train('a', 1)
def setUp(self): self.t = Train('T', 10)
def setUp(self) -> None: self.train = Train('BDJ', 50)
def setUp(self) -> None: self.train = Train("Bobby", 5)
def setUp(self): self.train = Train('BDJ', 2) self.passengers = []
def setUp(self): self.train = Train(self.name, self.capacity)
def setUp(self): self.train = Train("Train", 2)
def test_init_shouldInitialize(self): train = Train('test name', 100) self.assertEqual('test name', train.name) self.assertEqual(100, train.capacity) self.assertEqual([], train.passengers)
def setUp(self): self.train = Train("Test", 10)
def setUp(self) -> None: self.train = Train('test_name', 30)
def setUp(self): self.train = Train('Test name', 2)