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)
Beispiel #2
0
    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)
Beispiel #3
0
 def test_create_and_add_new_employee(self):
     # TODO write this test and then remove the self.fail() statement
     # Add some employees and verify they are present in the PhoneAssignments.employees list
     employee1 = Employee(1, 'Zion')
     testAssignmentMgr = PhoneAssignments()
     testAssignmentMgr.add_employee(employee1)
     self.assertIn(employee1, testAssignmentMgr.employees)  
Beispiel #4
0
    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

        test_employee1 = Employee(1, 'Mike')
        test_employee2 = Employee(2, 'Amanda')
        test_employee3 = Employee(3, 'Jake')

        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, test_employee1)
        testAssignmentMgr.assign(testPhone2, test_employee2)

        testAssignmentMgr.un_assign(testPhone1)

        self.assertTrue(testPhone1.employee_id == None)
Beispiel #5
0
    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)
Beispiel #6
0
    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))
Beispiel #7
0
    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)
Beispiel #8
0
    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)
Beispiel #9
0
 def test_create_and_add_new_employee(self):
     # write this test and then remove the self.fail() statement
     # Add some employees and verify they are present in the PhoneAssignments.employees list
     testAssignmentMgr = PhoneAssignments()
     test_employee = Employee(1, 'Yanis Varoufakis')
     testAssignmentMgr.add_employee(test_employee)
     self.assertIn(test_employee, testAssignmentMgr.employees)
 def test_create_and_add_new_employee(self):
     # TODO write this test and then remove the self.fail() statement
     # Add some employees and verify they are present in the PhoneAssignments.employees list
     test_employee1 = Employee(2, 'Gary')
     test_PhoneAssignments = PhoneAssignments()
     test_PhoneAssignments.add_employee(test_employee1)
     self.assertIn('Gary', test_PhoneAssignments.employees)
Beispiel #11
0
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
Beispiel #12
0
    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)
Beispiel #13
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)
 def test_create_and_add_new_employee(self):
     # DONE write this test and then remove the self.fail() statement
     # Add some employees and verify they are present in the PhoneAssignments.employees list
     testAssignmentMgr = PhoneAssignments()
     testAssignmentMgr.add_employee('Sarah')
     testAssignmentMgr.add_employee('Thomas')
     self.assertIn('Sarah', testAssignmentMgr.employees)
     self.assertIn('Thomas', testAssignmentMgr.employees)
    def test_create_and_add_new_employee(self):
        # Add some employees and verify they are present in the PhoneAssignments.employees list
        testEmployee = Employee(1, 'Test Name')
        testAssignmentMgt = PhoneAssignments()

        testAssignmentMgt.add_employee(testEmployee)

        self.assertIn(testEmployee, testAssignmentMgt.employees)
Beispiel #16
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
        testAssignmentMgr = PhoneAssignments()
        testAssignmentMgr.add_employee(Employee(1, 'TestEmployee1'))
        testPhone1 = Phone(1, 'Apple', 'iPhone 6')
        testAssignmentMgr.add_phone(testPhone1)

        self.assertEqual(testPhone1.employee_id, 1)
Beispiel #17
0
 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.
     testEmployee = Employee(1, 'Qaalib')
     testPhone = Phone(1, 'Apple', 'IPhone 10')
     testManager = PhoneAssignments()
     testManager.add_phone(testPhone)
     testManager.add_employee(testEmployee)
     self.assertEqual(testPhone, testManager.assign(testPhone.id, testEmployee))
Beispiel #18
0
    def test_create_and_add_employee_with_duplicate_id(self):
        test_assignment_mgr = PhoneAssignments()

        test_employee1 = Employee(1, 'Kitty')
        test_employee2 = Employee(1, 'Puppy')

        test_assignment_mgr.add_employee(test_employee1)
        with self.assertRaises(PhoneError):
            test_assignment_mgr.add_employee(test_employee2)
Beispiel #19
0
    def test_create_and_add_employee_with_duplicate_id(self):
        # TODO write this test and then remove the self.fail() statement
        # TODO you'll need to fix the add_employee method in PhoneAssignments to make this test PhoneAssignments
        # This method will be similar to test_create_and_add_phone_with_duplicate_id
        testAssignmentMgr = PhoneAssignments()
        testAssignmentMgr.add_employee(Employee(1, 'TestEmployee1'))

        with self.assertRaises(PhoneError):
            testAssignmentMgr.add_phone(Employee(1, 'TestEmployee2'))
Beispiel #20
0
    def test_create_and_add_employee_with_duplicate_id(self):
        test_assignment_mgr = PhoneAssignments()

        emp_1 = Employee(1, "John Locke")
        emp_2 = Employee(1, "Jack Sheppard")

        test_assignment_mgr.add_employee(emp_1)
        with self.assertRaises(EmployeeError):
            test_assignment_mgr.add_employee(emp_2)
Beispiel #21
0
    def test_create_and_add_employee_with_duplicate_id(self):
        test_employee1 = Employee(1, 'Colin Jost')
        test_employee2 = Employee(1, 'Michael Che')

        test_assignment_manager = PhoneAssignments()
        test_assignment_manager.add_employee(test_employee1)

        with self.assertRaises(PhoneError):
            test_assignment_manager.add_employee(test_employee2)
Beispiel #22
0
    def test_create_and_add_employee_with_duplicate_id(self):

        testEmployee1 = Employee(1, 'Mark')
        testEmployee2 = Employee(1, 'Ingrid')

        testAssignmentMgr = PhoneAssignments()
        testAssignmentMgr.add_employee(testEmployee1)

        with self.assertRaises(PhoneError):
            testAssignmentMgr.add_employee(testEmployee2)
 def test_create_and_add_employee_with_duplicate_id(self):
     # TODO write this test and then remove the self.fail() statement
     # TODO you'll need to fix the add_employee method in PhoneAssignments to make this test PhoneAssignments
     # This method will be similar to test_create_and_add_phone_with_duplicate_id
     employee_a = Employee(12345, 'Bill')
     employee_b = Employee(12345, 'Bob')
     test_assignment = PhoneAssignments()
     test_assignment.add_employee(employee_a)
     with self.assertRaises(PhoneError):
         test_assignment.add_employee(employee_b)
Beispiel #24
0
 def test_create_and_add_new_employee(self):
     # TODO write this test and then remove the self.fail() statement
     # Add some employees and verify they are present in the PhoneAssignments.employees list
     testEmployee1 = Employee(1, 'Taylor Swift')
     testEmployee2 = Employee(2, 'Kanye West')
     testAssignmentMgr = PhoneAssignments()
     testAssignmentMgr.add_employee(testEmployee1)
     testAssignmentMgr.add_employee(testEmployee2)
     self.assertTrue(testEmployee1, testAssignmentMgr.employees)
     self.assertTrue(testEmployee2, testAssignmentMgr.employees)
Beispiel #25
0
    def test_assign_phone_to_the_employee_who_already_has_this_phone(self):
        test_phone1 = Phone(1, "Bedrock", "Pterodactyl")
        test_employee1 = Employee(1, "Fred Flintstone")

        test_assignments_mgr = PhoneAssignments()
        test_assignments_mgr.add_phone(test_phone1)
        test_assignments_mgr.add_employee(test_employee1)
        test_assignments_mgr.assign(test_phone1.id, test_employee1)

        self.assertIsNone(test_assignments_mgr.assign(test_phone1, test_employee1))
Beispiel #26
0
    def test_assign_phone_to_employee(self):
        test_phone1 = Phone(1, "Samsung", "Galaxy S2")
        test_employee1 = Employee(1, "Kitty Cat")

        test_assignments_mgr = PhoneAssignments()
        test_assignments_mgr.add_phone(test_phone1)
        test_assignments_mgr.add_employee(test_employee1)
        test_assignments_mgr.assign(test_phone1.id, test_employee1)

        self.assertEqual(test_phone1.employee_id, test_employee1.id)
    def test_create_and_add_employee_with_duplicate_id(self):
        #Tests that duplicate IDs raises error.
        testEmployee1 = Employee(1, 'Test Name 1')
        testEmployee2 = Employee(1, 'Test Name 2')

        testAssignmentMgr = PhoneAssignments()
        testAssignmentMgr.add_employee(testEmployee1)

        with self.assertRaises(PhoneError):
            testAssignmentMgr.add_employee(testEmployee2)
Beispiel #28
0
 def test_create_and_add_employee_with_duplicate_id(self):
     # TODO write this test and then remove the self.fail() statement
     # TODO you'll need to fix the add_employee method in PhoneAssignments to make this test PhoneAssignments
     # This method will be similar to test_create_and_add_phone_with_duplicate_id
     testAssignmentMgr = PhoneAssignments()
     employee1 = Employee(1, 'Zion') #create employee 1
     testAssignmentMgr.add_employee(employee1) #add employee 1
     employee2 = Employee(1, 'Acadia') #this employee has same ID as empl 1
     with self.assertRaises(PhoneError):#trying to add an employee w/ dupl Id should raise a Phone Error
         testAssignmentMgr.add_employee(employee2)
Beispiel #29
0
    def test_assign_phone_to_employee(self):

        testEmployee1 = Employee(1, 'Mark')
        testPhone1 = Phone(43, 'Apple', 'iPhone 2')
        testAssignmentMgr = PhoneAssignments()

        testAssignmentMgr.add_employee(testEmployee1)
        testAssignmentMgr.add_phone(testPhone1)
        testAssignmentMgr.assign(43, testEmployee1)

        self.assertTrue(testPhone1.employee_id == 1)
    def test_create_and_add_employee_with_duplicate_id(self):
        # TODO write this test and then remove the self.fail() statement
        # TODO you'll need to fix the add_employee method in PhoneAssignments to make this test PhoneAssignments
        # This method will be similar to test_create_and_add_phone_with_duplicate_id
        test_employee1 = Employee(1, 'David Hasselhoff')
        test_employee2 = Employee(1, 'Gary Coleman')
        test_PhoneAssignments = PhoneAssignments()
        test_PhoneAssignments.add_employee(test_employee1)

        with self.assertRaises(PhoneError):
            test_PhoneAssignments.add_employee(test_employee2)