コード例 #1
0
    def test_assign_phone_to_employee(self):
        # TODO write this test and remove the self.fail() statement
        # TODO you'll need to fix the assign method in PhoneAssignments
        test_employee1 = Employee(1, 'Mike')
        test_employee2 = Employee(2, 'Amanda')
        test_employee3 = Employee(3, 'Jake')

        testPhone1 = Phone(1, 'Apple', 'iPhone 6')
        testPhone2 = Phone(2, 'Apple', 'iPhone 5')
        testPhone3 = Phone(3, 'Samsung', 'Edge')

        testAssignmentMgr = PhoneAssignments()
        testAssignmentMgr.add_employee(test_employee1)
        testAssignmentMgr.add_employee(test_employee2)
        testAssignmentMgr.add_employee(test_employee3)

        testAssignmentMgr.add_phone(testPhone1)
        testAssignmentMgr.add_phone(testPhone2)
        testAssignmentMgr.add_phone(testPhone3)

        testAssignmentMgr.assign(testPhone1.id, test_employee1)
        testAssignmentMgr.assign(testPhone2.id, test_employee2)
        testAssignmentMgr.assign(testPhone3.id, test_employee3)

        self.assertTrue(testPhone1.is_assigned())
        self.assertTrue(testPhone1.employee_id == test_employee1.id)
コード例 #2
0
    def test_assign_phone_to_employee(self):
        # TODO write this test and remove the self.fail() statement
        # TODO you'll need to fix the assign method in PhoneAssignments

        employee = Employee(1, 'John')
        testAssignmentMgr = PhoneAssignments()
        phone = Phone(1, 'Apple', 'iPhone 6')
        testAssignmentMgr.add_phone(phone)
        testAssignmentMgr.add_employee(employee)
        testAssignmentMgr.assign(phone.id, employee)

        self.assertIsNotNone(phone.is_assigned())