Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    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))
Exemple #4
0
    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)
Exemple #5
0
    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)
Exemple #6
0
    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)
Exemple #8
0
    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)
Exemple #10
0
 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))
Exemple #11
0
 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))
Exemple #12
0
 def setUp(self):
     self.train = Train('a', 1)
Exemple #13
0
 def setUp(self):
     self.t = Train('T', 10)
Exemple #14
0
 def setUp(self) -> None:
     self.train = Train('BDJ', 50)
Exemple #15
0
 def setUp(self) -> None:
     self.train = Train("Bobby", 5)
Exemple #16
0
 def setUp(self):
     self.train = Train('BDJ', 2)
     self.passengers = []
Exemple #17
0
 def setUp(self):
     self.train = Train(self.name, self.capacity)
Exemple #18
0
 def setUp(self):
     self.train = Train("Train", 2)
Exemple #19
0
    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)
Exemple #20
0
 def setUp(self):
     self.train = Train("Test", 10)
 def setUp(self) -> None:
     self.train = Train('test_name', 30)
Exemple #22
0
 def setUp(self):
     self.train = Train('Test name', 2)