Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 7
0
 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)
Exemplo n.º 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))
Exemplo n.º 9
0
 def setUp(self):
     self.train = Train("Orient", 50)
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 12
0
 def setUp(self):
     self.train = Train('a', 1)
Exemplo n.º 13
0
 def setUp(self):
     self.t = Train('T', 10)
Exemplo n.º 14
0
 def setUp(self) -> None:
     self.train = Train('BDJ', 50)
Exemplo n.º 15
0
 def setUp(self) -> None:
     self.train = Train("Bobby", 5)
Exemplo n.º 16
0
 def setUp(self):
     self.train = Train('BDJ', 2)
     self.passengers = []
Exemplo n.º 17
0
 def setUp(self):
     self.train = Train(self.name, self.capacity)
Exemplo n.º 18
0
 def setUp(self):
     self.train = Train("Train", 2)
Exemplo n.º 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)
Exemplo n.º 20
0
 def setUp(self):
     self.train = Train("Test", 10)
Exemplo n.º 21
0
 def setUp(self) -> None:
     self.train = Train('test_name', 30)
Exemplo n.º 22
0
 def setUp(self):
     self.train = Train('Test name', 2)