コード例 #1
0
ファイル: test_spaceship.py プロジェクト: mariatmv/PythonOOP
    def test_initialization(self):
        test = Spaceship("ime", 300)
        self.assertEqual("ime", test.name)
        self.assertEqual(300, test.capacity)
        self.assertEqual([], test.astronauts)

        for attr in ['name', 'capacity', 'astronauts']:
            self.assertTrue(hasattr(test, attr))
コード例 #2
0
 def setUp(self):
     self.spaceship = Spaceship('Apollo 13', 2)
コード例 #3
0
ファイル: test_spaceship.py プロジェクト: mariatmv/PythonOOP
 def test_remove_should_raise_exception_if_astronaut_doesnt_exist(self):
     test = Spaceship("ime", 1)
     with self.assertRaises(ValueError) as context:
         test.remove('zdr')
         self.assertEqual(context, "Astronaut Not Found")
コード例 #4
0
ファイル: test_spaceship.py プロジェクト: mariatmv/PythonOOP
 def test_should_remove_astronaut(self):
     test = Spaceship("ime", 2)
     test.add('zdr')
     self.assertEqual('zdr', test.astronauts[0])
     test.remove('zdr')
     self.assertEqual([], test.astronauts)
コード例 #5
0
ファイル: test_spaceship.py プロジェクト: mariatmv/PythonOOP
 def test_should_add_new_astronaut(self):
     test = Spaceship("ime", 2)
     test.add('zdr')
     self.assertEqual('zdr', test.astronauts[0])
     self.assertEqual("Added astronaut ime", test.add('ime'))
コード例 #6
0
ファイル: test_spaceship.py プロジェクト: mariatmv/PythonOOP
 def test_add_should_raise_exception_when_astronaut_already_exist(self):
     test = Spaceship("ime", 2)
     test.astronauts.append('zdr')
     with self.assertRaises(ValueError) as context:
         test.add('zdr')
         self.assertEqual("Astronaut zdr Exists", context)
コード例 #7
0
ファイル: test_spaceship.py プロジェクト: mariatmv/PythonOOP
 def test_add_should_raise_exception_when_not_enough_capacity(self):
     test = Spaceship("ime", 0)
     with self.assertRaises(ValueError) as context:
         test.add('nqkakvo ime')
         self.assertEqual("Spaceship is full", context)
コード例 #8
0
 def setUp(self) -> None:
     self.ship = Spaceship('Apollo', 3)
コード例 #9
0
 def setUp(self) -> None:
     self.spaceship = Spaceship("Voyager", 1)