Пример #1
0
class StaffTestCase(unittest.TestCase):

    def setUp(self):
        pre_populate.populate()
        self.me = Staff('john', 'doe')

    def tearDown(self):
        del self.me
        reset.reset()

    def test_class(self):
        '''test if object is of class Staff'''
        self.assertTrue(isinstance(self.me, Staff),
                        'object is not an instance of Staff')

    def test_subclass(self):
        '''test object is a subclass of Person'''
        self.assertTrue(issubclass(type(self.me), Person),
                        'object is not a subclass of Person')

    def test_names(self):
        '''test first and last names set correctly'''
        self.assertEqual(self.me.first_name, 'john',
                         'object first name incorrect')
        self.assertEqual(self.me.last_name, 'doe',
                         'object last name incorrect')

    def test_assign_staff_livingroom(self):
        '''test staff cannot be assigned living rooms'''

        with self.assertRaises(AttributeError):
            self.me.assign_living()