def test_get_phone_info_for_employee(self): # Test if correct phone info is returned testEmployee1 = Employee(1, 'Marissa') testEmployee2 = Employee(2, 'Christine') testEmployee3 = Employee(3, 'Kimarlee') testEmployee4 = Employee(4, 'Jennifer') testPhone1 = Phone(1, 'Apple', 'iPhone 6') testPhone2 = Phone(2, 'Apple', 'iPhone 5') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_employee(testEmployee2) testAssignmentMgr.add_employee(testEmployee3) testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.add_phone(testPhone2) testAssignmentMgr.assign(testPhone1.id, testEmployee1) testAssignmentMgr.assign(testPhone2.id, testEmployee2) self.assertTrue(testPhone1.id, testAssignmentMgr.phone_info(testEmployee1)) self.assertTrue(testPhone2.id, testAssignmentMgr.phone_info(testEmployee2)) # Return None for testEmployee3 who does not have a phone self.assertEqual(None, testAssignmentMgr.phone_info(testEmployee3)) # Raises PhoneError for testEmployee4 who has not been added with self.assertRaises(PhoneError): testAssignmentMgr.phone_info(testEmployee4)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist test_PhoneAssignments = PhoneAssignments() employee1 = Employee(1, 'Alice') employee2 = Employee(2, 'Bob') employee3 = Employee(3, 'Caitie') employee4 = Employee(4, 'Dan') phone1 = Phone(1, 'Samsung', 'Galaxy Note 15') phone2 = Phone(2, 'Samsung', 'Ultra HD') test_PhoneAssignments.add_employee(employee1) test_PhoneAssignments.add_employee(employee2) test_PhoneAssignments.add_employee(employee3) test_PhoneAssignments.add_phone(phone1) test_PhoneAssignments.add_phone(phone2) test_PhoneAssignments.assign(phone1.id, employee1) test_PhoneAssignments.assign(phone2.id, employee2) print(test_PhoneAssignments.phone_info(employee1)) print(test_PhoneAssignments.phone_info(employee2)) self.assertIsNone(test_PhoneAssignments.phone_info(employee3)) with self.assertRaises(PhoneError): test_PhoneAssignments.phone_info(employee4)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist testPhone1 = Phone(1, 'Apple', 'iPhone 6') testPhone2 = Phone(2, 'Apple', 'iPhone 5') testEmployee1 = Employee(1, 'Alice') testEmployee2 = Employee(2, 'Bill') testEmployee3 = Employee(3, 'Ted') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.add_phone(testPhone2) testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_employee(testEmployee2) testAssignmentMgr.add_employee(testEmployee3) testAssignmentMgr.assign(testPhone1.id, testEmployee1) testAssignmentMgr.assign(testPhone2.id, testEmployee2) self.assertEqual(testAssignmentMgr.phone_info(testEmployee1), testPhone1) self.assertEqual(testAssignmentMgr.phone_info(testEmployee2), testPhone2) self.assertIsNone(testAssignmentMgr.phone_info(testEmployee3)) with self.assertRaises(PhoneError): testAssignmentMgr.assign(testAssignmentMgr.phone_info(None))
def test_get_phone_info_for_employee(self): # write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # check that the method returns None if the employee does not have a phone # check that the method raises an PhoneError if the employee does not exist testAssignmentMgr = PhoneAssignments() employee_with_phone = Employee(1, 'Chimamanda Ngozi Adichie') employee_without_phone = Employee(2, 'William Goldman') nonexistent_employee = Employee(3, 'S. Morgenstern') test_phone = Phone(1, 'Danger', 'Hiptop') testAssignmentMgr.add_employee(employee_with_phone) testAssignmentMgr.add_employee(employee_without_phone) testAssignmentMgr.add_phone(test_phone) testAssignmentMgr.assign(1, employee_with_phone) self.assertEquals( testAssignmentMgr.phone_info(employee_with_phone), test_phone) # test that we can get employee_with_phone's phone self.assertIsNone( testAssignmentMgr.phone_info(employee_without_phone) ) # test that getting phone info for employee_without_phone returns None with self.assertRaises( PhoneError ): # test that getting phone info for a nonexistent_employee raises an exception testAssignmentMgr.phone_info(nonexistent_employee)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist test_employee1 = Employee(1, 'Mike') test_employee2 = Employee(2, 'Amanda') test_employee3 = Employee(3, 'Jake') test_employee10 = Employee(10, 'Does not exist') testPhone1 = Phone(1, 'Apple', 'iPhone 5') testPhone2 = Phone(2, '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.assign(testPhone1.id, test_employee1) testAssignmentMgr.assign(testPhone2.id, test_employee2) self.assertTrue( testAssignmentMgr.phone_info(test_employee1) == testPhone1) self.assertTrue( testAssignmentMgr.phone_info(test_employee2) == testPhone2) self.assertIsNone(testAssignmentMgr.phone_info(test_employee3)) with self.assertRaises(PhoneError): testAssignmentMgr.phone_info(test_employee10)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist assignments = PhoneAssignments() phone1 = Phone(1, 'Samsung', 'Galaxy Note 7') phone2 = Phone(2, 'Samsung', 'Galaxy S III') phone3 = Phone(3, 'Samsung', 'Galaxy A7') assignments.add_phone(phone1) assignments.add_phone(phone2) assignments.add_phone(phone3) employee1 = Employee(1, 'Alice') employee2 = Employee(2, 'Bill') employee3 = Employee(3, 'Ted') employee4 = Employee(4, 'Fred') assignments.add_employee(employee1) assignments.add_employee(employee2) assignments.add_employee(employee3) assignments.assign(phone1.id, employee2) # Assign phone 1 to employee 2 assignments.assign(phone2.id, employee3) # Assign phone 2 to employee 3 self.assertEqual(phone1, assignments.phone_info(employee2)) self.assertIsNone(assignments.phone_info(employee1)) with self.assertRaises(PhoneError): assignments.phone_info(employee4)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist testEmployee1 = Employee(1, 'Dani') testEmployee2 = Employee(2, 'Beryl') testEmployee3 = Employee(3, 'Archie') testEmployee4 = None testPhone1 = Phone(1, 'Apple', 'New iPhone 10 Pro XL lite++ Max') testPhone2 = Phone(2, 'Nintendo', 'Nintendo Switch Cell Phone') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_employee(testEmployee2) testAssignmentMgr.add_employee(testEmployee3) testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.add_phone(testPhone2) testAssignmentMgr.assign(testPhone1.id, testEmployee1) testAssignmentMgr.assign(testPhone2.id, testEmployee2) # self.assertEqual('ID: 1 Make: Apple Model: New iPhone 10 Pro XL lite++ Max Assigned to Employee ID: 1', testAssignmentMgr.phone_info(testEmployee1)) # self.assertEqual('ID: 2 Make: Nintendo Model: Nintendo Switch Cell Phone Assigned to Employee ID: 2', testAssignmentMgr.phone_info(testEmployee2)) with self.assertRaises(PhoneError): testAssignmentMgr.phone_info(testEmployee4)
def main(): assignments = PhoneAssignments() phone1 = Phone(1, 'Samsung', 'Galaxy Note 7') phone2 = Phone(2, 'Samsung', 'Galaxy S III') phone3 = Phone(3, 'Samsung', 'Galaxy A7') assignments.add_phone(phone1) assignments.add_phone(phone2) assignments.add_phone(phone3) employee1 = Employee(1, 'Alice') employee2 = Employee(2, 'Bill') employee3 = Employee(3, 'Ted') assignments.add_employee(employee1) assignments.add_employee(employee2) assignments.add_employee(employee3) assignments.assign(phone1.id, employee2) # Assign phone 1 to employee 2 assignments.assign(phone2.id, employee3) # Assign phone 2 to employee 3 print( assignments.phone_info(employee1)) # Employee 1, no phone. Prints None print(assignments.phone_info(employee2)) # Employee 2, has Phone 1 print(assignments.phone_info(employee3)) # Employee 3 has Phone 2 assignments.un_assign( phone2.id) # un-assign phone 2 (which belonged to employee 3) print(assignments.phone_info(employee3)) # None assignments.assign(phone3.id, employee3) # Assign phone 3 to employee 3
def test_get_phone_info_for_employee(self): # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # check that the method returns None if the employee does not have a phone # check that the method raises an PhoneError if the employee does not exist testPhone1 = Phone(1, 'Apple', 'iPhone 6') testEmployee1 = Employee(1, "Mark Hamil") testEmployee2 = Employee(2, "Carrie Fisher") testPhoneAssigmentsMgr = PhoneAssignments() testPhoneAssigmentsMgr.assign(testPhone1, testEmployee1) self.assertTrue(testPhoneAssigmentsMgr.phone_info(testEmployee1)==testPhone1) self.assertIsNone(testPhoneAssigmentsMgr.phone_info(testEmployee2)) with self.assertRaises(PhoneError): testPhoneAssigmentsMgr.phone_info(testEmployee3)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist employee1 = Employee(1, 'Jack') employee2 = Employee(2, 'Jacob') phone1 = Phone(1, 'Apple', 'iPhone 6') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(employee1) testAssignmentMgr.add_phone(phone1) self.assertIsNone(testAssignmentMgr.phone_info(employee1)) with self.assertRaises(PhoneError): testAssignmentMgr.phone_info(employee2)
def test_get_phone_info_for_employee(self): test_phone1 = Phone(1, "Samsung", "Galaxy S2") test_phone2 = Phone(2, "Bedrock", "Pterodactyl") test_employee1 = Employee(1, "Kitty Cat") test_employee2 = Employee(2, "Puppy Dog") test_employee3 = Employee(3, "Fred Flintstone") test_assignments_mgr = PhoneAssignments() test_assignments_mgr.add_phone(test_phone1) test_assignments_mgr.add_phone(test_phone2) test_assignments_mgr.add_employee(test_employee1) test_assignments_mgr.add_employee(test_employee2) test_assignments_mgr.assign(test_phone1.id, test_employee1) self.assertEqual(test_phone1, test_assignments_mgr.phone_info(test_employee1)) self.assertIsNone(test_assignments_mgr.phone_info(test_employee2)) with self.assertRaises(PhoneError): test_assignments_mgr.phone_info(test_employee3)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist testPhone1 = Phone(1, 'Apple', 'iPhone 6') testEmployee1 = Employee(1, "Jim Carey") testEmployee2 = Employee(2, "Chris Baker") testPhoneAssigmentsMgr = PhoneAssignments() testPhoneAssigmentsMgr.assign(testPhone1, testEmployee1) self.assertTrue(testPhoneAssigmentsMgr.phone_info(testEmployee1)==testPhone1) self.assertIsNone(testPhoneAssigmentsMgr.phone_info(testEmployee2)) with self.assertRaises(PhoneError): testPhoneAssigmentsMgr.phone_info(testEmployee3)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist testEmployee = Employee(1, 'Qaalib') testEmployee2 = Employee(2, 'Snoopy') testPhone = Phone(1, 'Apple', 'IPhone 10') testPhone2 = Phone(2, 'Apple', 'IPhone X') testManager = PhoneAssignments() testManager.add_employee(testEmployee) testManager.add_phone(testPhone2) testManager.add_phone(testPhone) self.assertIsNone(testManager.phone_info(testEmployee)) with self.assertRaises(PhoneError): testManager.phone_info(testEmployee2)
def test_un_assign_phone(self): # TODO write this test and remove the self.fail() statement # Assign a phone, unassign the phone, verify the employee_id is None testEmployee = Employee(1, 'Andre the Giant') testPhone = Phone(1, 'Google', 'Pixel 3a') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.assign(testPhone.id, testEmployee) testAssignmentMgr.un_assign(testPhone.id) self.assertIsNone(testAssignmentMgr.phone_info(testEmployee))
def test_assign_phone_to_the_employee_who_already_has_this_phone(self): # TODO The method should not make any changes but NOT raise a PhoneError if a phone # is assigned to the same user it is currenly assigned to. testAssignmentMgr = PhoneAssignments() employee1 = Employee(1, 'Bryce') #create an employee testAssignmentMgr.add_employee(employee1) #add employee testPhone1 = Phone(1, 'Apple', 'iPhone 6') #create a phone testAssignmentMgr.add_phone(testPhone1) #add the phone testAssignmentMgr.assign(testPhone1.id, employee1) #assign phoneID 1 to employee1 testAssignmentMgr.assign(testPhone1.id, employee1) #assign same phone to same employee self.assertEqual(1, testAssignmentMgr.phone_info(employee1).id) #asserting that the phone belonging to emp1 is phone 1
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 testAssignmentMgr = PhoneAssignments() employee1 = Employee(1, 'Zion') #create an employee testAssignmentMgr.add_employee(employee1) #add employee testPhone3 = Phone(3, 'Apple', 'iPhone 7') #create a phone testAssignmentMgr.add_phone(testPhone3) #add the phone testAssignmentMgr.assign(testPhone3.id, employee1) #assign phoneID 3 to employee1 #assert that when phone info is called for empl 1, the phoneID is 3 self.assertEqual(3, testAssignmentMgr.phone_info(employee1).id )
def main(): assignments = PhoneAssignments() phone1 = Phone(1, 'Samsung', 'Galaxy Note 7') phone2 = Phone(2, 'Samsung', 'Galaxy S III') phone3 = Phone(3, 'Samsung', 'Galaxy A7') # phone4 = Phone(3, 'sss', 'garb') assignments.add_phone(phone1) assignments.add_phone(phone2) assignments.add_phone(phone3) # assignments.add_phone(phone4) employee1 = Employee(1, 'Alice') employee2 = Employee(2, 'Bill') employee3 = Employee(3, 'Ted') # employee4 = Employee(3, 'Ted') assignments.add_employee(employee1) assignments.add_employee(employee2) assignments.add_employee(employee3) # assignments.add_employee(employee4) assignments.assign(phone1.id, employee2) # Assign phone 1 to employee 2 assignments.assign(phone2.id, employee3) # Assign phone 2 to employee 3 print( assignments.phone_info(employee1)) # Employee 1, no phone. Prints None print(assignments.phone_info(employee2)) # Employee 2, has Phone 1 print(assignments.phone_info(employee3)) # Employee 3 has Phone 2 assignments.un_assign( phone2.id) # un-assign phone 2 (which belonged to employee 3) print(assignments.phone_info(employee3)) # None assignments.assign(phone3.id, employee3) # Assign phone 3 to employee 3 assignments.assign( phone3.id, employee3 ) # Reassign phone 3 to employee3. TODO this should fail; employee3 should not be able to have two phones
def main(): assignments = PhoneAssignments() phone1 = Phone(1, 'Samsung', 'Galaxy Note 7') phone2 = Phone(2, 'Samsung', 'Galaxy S III') phone3 = Phone(3, 'Samsung', 'Galaxy A7') phone4 = Phone(3, 'Samsung', 'Galaxy s9') assignments.add_phone(phone1) assignments.add_phone(phone2) assignments.add_phone(phone3) assignments.add_phone(phone4) # This should fail because phone 4 has the same ID as phone 3 employee1 = Employee(1, 'Alice') employee2 = Employee(2, 'Bill') employee3 = Employee(3, 'Ted') employee4 = Employee(3, 'Tom') assignments.add_employee(employee1) assignments.add_employee(employee2) assignments.add_employee(employee3) assignments.add_employee(employee4) # This should fail out because employee 4 has the same ID as employee 3 assignments.assign(phone1.id, employee2) # Assign phone 1 to employee 2 assignments.assign(phone2.id, employee3) # Assign phone 2 to employee 3 print(assignments.phone_info(employee1)) # Employee 1, no phone. Prints None print(assignments.phone_info(employee2)) # Employee 2, has Phone 1 print(assignments.phone_info(employee3)) # Employee 3 has Phone 2 print(assignments.phone_info(employee4)) # This should fail as employee 4 was not added assignments.un_assign(phone2.id) # un-assign phone 2 (which belonged to employee 3) print(assignments.phone_info(employee3)) # None assignments.assign(phone3.id, employee3) # Assign phone 3 to employee 3 assignments.assign(phone2.id, employee3) # Reassign phone 2 to employee3. TODO this should fail; employee3 should not be able to have two phones print(assignments.phone_info(employee3)) # Employee 3 should have phone 2
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist testEmployee1 = Employee(1, 'Mark') testEmployee2 = Employee(2, 'Blunk') testPhone1 = Phone(43, 'Samsung', 'Galaxy S9') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.assign(43, testEmployee1) empPhone = testAssignmentMgr.phone_info(testEmployee1) self.assertEquals(empPhone, testPhone1) with self.assertRaises(PhoneError): testAssignmentMgr.phone_info(testEmployee2)
def test_assign_phone_to_employee(self): # write this test and remove the self.fail() statement # you'll need to fix the assign method in PhoneAssignments testAssignmentMgr = PhoneAssignments() test_employee = Employee(1, 'Edward Herman') test_phone = Phone(1, 'Motorola', 'Razr') testAssignmentMgr.add_employee(test_employee) testAssignmentMgr.add_phone(test_phone) testAssignmentMgr.assign(1, test_employee) self.assertEquals(testAssignmentMgr.phone_info(test_employee), test_phone)
def test_get_phone_info_for_employee(self): test_employee1 = Employee(1, 'Probability the Rap Artist') test_employee2 = Employee(2, 'Immature Lucchese') test_employee3 = Employee(3, 'Kendrick Notsocool') test_phone1 = Phone(1, 'Orange', 'aPhone 3') test_phone2 = Phone(2, 'Orange', 'ePhone 40') test_phone3 = Phone(3, 'Orange', 'iPhone -8') test_assignment_manager = PhoneAssignments() test_assignment_manager.add_employee(test_employee1) test_assignment_manager.add_employee(test_employee2) test_assignment_manager.add_phone(test_phone2) test_assignment_manager.add_phone(test_phone3) test_assignment_manager.assign(2, test_employee2) phone1 = test_assignment_manager.phone_info(test_employee1) phone2 = test_assignment_manager.phone_info(test_employee2) self.assertIsNone(phone1) self.assertEqual(phone2, test_phone2) with self.assertRaises(PhoneError): phone3 = test_assignment_manager.phone_info(test_employee3)
def test_un_assign_phone(self): # Test unassign employee equal to None testEmployee1 = Employee(1, 'Marissa') testPhone1 = Phone(1, 'Apple', 'iPhone 6') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.assign(testPhone1.id, testEmployee1) testAssignmentMgr.un_assign(testPhone1.id) self.assertEqual(None, testAssignmentMgr.phone_info(testEmployee1))
def test_get_phone_info_for_employee(self): # Checks that the method returns None if the employee does not have a phone # Checks that the method raises an PhoneError if the employee does not exist testEmployee1 = Employee(1, 'Test Name 1') testEmployee2 = Employee(2, 'Test Name 2') fakeEmployee = Employee(3, 'Fake Name') testPhone1 = Phone(1, 'Test Brand 1', 'Test Model 1') testPhone2 = Phone(2, 'Test Brand 2', 'Test Model 2') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_employee(testEmployee2) testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.add_phone(testPhone2) testAssignmentMgr.assign(1, testEmployee1) self.assertTrue( testAssignmentMgr.phone_info(testEmployee1) == testPhone1) self.assertTrue(testAssignmentMgr.phone_info(testEmployee2) == None) with self.assertRaises(PhoneError): testAssignmentMgr.phone_info(fakeEmployee)
def test_un_assign_phone(self): # TODO write this test and remove the self.fail() statement # Assign a phone, unasign the phone, verify the employee_id is None assignments = PhoneAssignments() phone1 = Phone(1, 'Samsung', 'Galaxy Note 7') assignments.add_phone(phone1) employee2 = Employee(2, 'Bill') assignments.add_employee(employee2) assignments.assign(phone1.id, employee2) assignments.un_assign(phone1.id) self.assertIsNone(assignments.phone_info(employee2))
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 assignments = PhoneAssignments() phone1 = Phone(1, 'Samsung', 'Galaxy Note 7') assignments.add_phone(phone1) employee2 = Employee(2, 'Bill') assignments.add_employee(employee2) assignments.assign(phone1.id, employee2) self.assertEqual(phone1, assignments.phone_info(employee2))
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned testAssignmentMgr = PhoneAssignments() testPhone1 = Phone(1, 'Apple', 'iPhone 6') testPhone2 = Phone(2, 'Apple', 'iPhone 5') testAssignmentMgr.add_phone(testPhone1)#add the two phones testAssignmentMgr.add_phone(testPhone2) employee1 = Employee(1, 'Zion') #create some employees employee2 = Employee(2, 'Acadia') testAssignmentMgr.add_employee(employee1) #add the employees testAssignmentMgr.add_employee(employee2) testAssignmentMgr.assign(testPhone2.id, employee1) #assign phone 2 to employee1 testAssignmentMgr.assign(testPhone1.id, employee2) #assign phone 1 to empl 2 self.assertEqual('iPhone 5', testAssignmentMgr.phone_info(employee1).model) self.assertEqual('iPhone 6', testAssignmentMgr.phone_info(employee2).model)
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned testEmployee1 = Employee(1, 'Tony') testEmployee2 = Employee(2,'Hiai') testPhone1 = Phone(1, 'Apple', 'iPhone 6') testPhone2 = Phone(2, 'Apple', 'iPhone 7') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_employee(testEmployee2) testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.add_phone(testPhone2) testAssignmentMgr.assign(testPhone1.id, testEmployee1) self.assertTrue(testPhone1, testAssignmentMgr.phone_info(testEmployee1))
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, testEmployee1 = Employee(1, 'Kobe') testEmployee2 = Employee(2, 'Jade') testPhone1 = Phone(1, 'Apple', 'iPhone 6') testPhone2 = Phone(2, 'Apple', 'iPhone 7') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.add_employee(testEmployee1) testAssignmentMgr.add_employee(testEmployee2) testAssignmentMgr.add_phone(testPhone1) testAssignmentMgr.add_phone(testPhone2) testAssignmentMgr.assign(testPhone1.id, testEmployee1) self.assertTrue(testPhone1, testAssignmentMgr.phone_info(testEmployee1))
def test_get_phone_info_for_employee(self): testphone1 = Phone(1, 'Phone1', 'Model1') testphone2 = Phone(2, 'Phone2', 'Model2') testEmployee1 = Employee(1, 'Employee1') testAssignmentMgr = PhoneAssignments() testAssignmentMgr.assign(testphone1.id, testEmployee1.id) # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned self.assertEqual(testphone1.id, testEmployee1.id) # TODO check that the method returns None if the employee does not have a phone self.assertNotEqual(testphone2.employee_id, testEmployee1.id) # TODO check that the method raises an PhoneError if the employee does not exist with self.assertRaises(PhoneError): return (testAssignmentMgr.phone_info(Employee(4, 'Name')))
def test_get_phone_info_for_employee(self): # TODO write this test and remove the self.fail() statement # Create some phones, and employees, assign a phone, # call phone_info and verify correct phone info is returned # TODO check that the method returns None if the employee does not have a phone # TODO check that the method raises an PhoneError if the employee does not exist testAssignmentMgr = PhoneAssignments() #create new phones testPhone1 = Phone(1, 'Apple', 'iPhone 6') #add new phones to the phone list testAssignmentMgr.add_phone(testPhone1) #create new employee employee1 = Employee(1, 'Alice') #add new employee to the employee list testAssignmentMgr.add_employee(employee1) #assign employee1 with phone1 testAssignmentMgr.assign(testPhone1.id, employee1) #phone_info returns the list of phone and employee_id employee_assigned = testAssignmentMgr.phone_info(employee1) #test employee id on the phone info is same as employee assigned self.assertEqual(testPhone1.employee_id, employee_assigned.employee_id)