コード例 #1
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)
コード例 #2
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
コード例 #3
0
    def test_un_assign_phone(self):
        # Assign a phone, unasign the phone, verify the employee_id is None
        testPhone1 = Phone(1, 'Apple', 'iPhone 6')
        testEmployee1 = Employee(1, "Mark Hamil")
        testPhoneAssigmentsMgr = PhoneAssignments()
        testPhoneAssigmentsMgr.assign(testPhone1, testEmployee1)
        testPhoneAssigmentsMgr.un_assign(testPhone1)

        self.assertTrue(testPhone1.employee_id == None)
コード例 #4
0
    def test_un_assign_phone(self):

        testEmployee1 = Employee(1, 'Mark')
        testPhone1 = Phone(21, 'Samsung', 'Galaxy S3')
        testAssignmentMgr = PhoneAssignments()

        testAssignmentMgr.assign(21, testEmployee1)
        testAssignmentMgr.un_assign(21)

        self.assertEquals(None, testPhone1.employee_id)
コード例 #5
0
    def test_un_assign_phone(self):
        # TODO write this test and remove the self.fail() statement
        # Assign a phone, un-assign the phone, verify the employee_id is None
        
        testPhone1 = Phone(1, 'Apple', 'iPhone 6')
        testEmployee1 = Employee(1, "Jim Carey")
        testPhoneAssigmentsMgr = PhoneAssignments()
        testPhoneAssigmentsMgr.assign(testPhone1, testEmployee1)
        testPhoneAssigmentsMgr.un_assign(testPhone1)

        self.assertTrue(testPhone1.employee_id == None)
コード例 #6
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
     testEmployee = Employee(1, 'Qaalib')
     testPhone = Phone(1, 'Apple', 'IPhone 10')
     testManager = PhoneAssignments()
     testManager.add_phone(testPhone)
     testManager.add_employee(testEmployee)
     testManager.assign(testPhone.id, testEmployee)
     testManager.un_assign(testPhone.id)
     self.assertIsNone(testPhone.employee_id)
コード例 #7
0
    def test_un_assign_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)
        test_assignments_mgr.un_assign(test_phone1.id)

        self.assertIsNone(test_assignments_mgr.phones[0].employee_id)
コード例 #8
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
     testPhone1 = Phone(1, 'Apple', 'iPhone 6') #create a phone object
     testAssignmentMgr = PhoneAssignments()
     testAssignmentMgr.add_phone(testPhone1) #add phone
     employee1 = Employee(1, 'Zion') #create and add an employee
     testAssignmentMgr.add_employee(employee1)
     testAssignmentMgr.assign(testPhone1.employee_id,employee1) #assign  phone ID 1 to employee1
     testAssignmentMgr.un_assign(testPhone1.id) #unassign phone ID 1
     self.assertIsNone(testAssignmentMgr.un_assign(testPhone1.id)) #assert that emp_id is None for phone 1
コード例 #9
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
        employee = Employee(1, 'Jack')
        phone = Phone(1, 'Apple', 'iPhone 6')
        testAssignmentMgr = PhoneAssignments()
        testAssignmentMgr.add_employee(employee)
        testAssignmentMgr.add_phone(phone)
        testAssignmentMgr.assign(phone.id, employee)
        testAssignmentMgr.un_assign(phone.id)

        self.assertIsNone(phone.employee_id)
コード例 #10
0
    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))
コード例 #11
0
    def test_un_assign_phone(self):
        # Assigns a phone, unasigns the phone, verifies the employee_id is None
        testEmployee = Employee(1, 'Test Name 1')
        testPhone = Phone(1, 'Test Brand', 'Test Model')

        testAssignmentMgr = PhoneAssignments()
        testAssignmentMgr.add_employee(testEmployee)
        testAssignmentMgr.add_phone(testPhone)

        testAssignmentMgr.assign(1, testEmployee)
        testAssignmentMgr.un_assign(1)

        self.assertTrue(testPhone.employee_id == None)
コード例 #12
0
    def test_un_assign_phone(self):
        # write this test and remove the self.fail() statement
        # Assign a phone, unasign the phone, verify the employee_id is None
        test_PhoneAssignments = PhoneAssignments()
        employee1 = Employee(1, 'Alice')
        phone1 = Phone(1, 'Samsung', 'Galaxy Note 15')

        test_PhoneAssignments.add_employee(employee1)
        test_PhoneAssignments.add_phone(phone1)

        test_PhoneAssignments.assign(phone1.id, employee1)
        test_PhoneAssignments.un_assign(phone1.id)
        self.assertIsNone(phone1.employee_id)
コード例 #13
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
        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))
コード例 #14
0
    def test_un_assign_phone(self):

        test_phone1 = Phone(1, 'Apple', 'iPhone 6')

        test_employee1 = Employee(1, "Dirk Gently")

        test_assignment_mgr = PhoneAssignments()
        test_assignment_mgr.add_phone(test_phone1)
        test_assignment_mgr.add_employee(test_employee1)

        test_assignment_mgr.assign(test_phone1.id, test_employee1)
        test_assignment_mgr.un_assign(test_phone1.id)

        self.assertIsNone(test_assignment_mgr.phones[0].employee_id)
コード例 #15
0
    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))
コード例 #16
0
    def test_un_assign_phone(self):
        # TODO write this test and remove the self.fail() statement
        testEmployee1 = Employee(1, 'Kobe')

        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.assertIsNone(testPhone1.employee_id)
コード例 #17
0
    def test_un_assign_phone(self):
        # write this test and remove the self.fail() statement
        # Assign a phone, unassign the phone, verify the employee_id is None
        testAssignmentMgr = PhoneAssignments()
        test_employee = Employee(1, 'Jane Austen')
        test_phone = Phone(1, 'Carrier', 'Pigeon')

        testAssignmentMgr.add_employee(test_employee)
        testAssignmentMgr.add_phone(test_phone)

        testAssignmentMgr.assign(1, test_employee)
        testAssignmentMgr.un_assign(1)

        self.assertIsNone(test_phone.employee_id)
コード例 #18
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
        testPhone1 = Phone(1, 'Apple', 'iPhone 6')
        testEmployee1 = Employee(1, 'Alice')

        testAssignmentMgr = PhoneAssignments()

        testAssignmentMgr.add_phone(testPhone1)
        testAssignmentMgr.add_employee(testEmployee1)

        testAssignmentMgr.assign(1, testEmployee1)
        testAssignmentMgr.un_assign(1)
        self.assertFalse(testAssignmentMgr.phones[0].is_assigned())
コード例 #19
0
    def test_un_assign_phone(self):
        test_phone = Phone(1, 'Apple', 'iPhone 420')
        test_employee = Employee(1, 'Snoop Dogg')

        test_assignment_manager = PhoneAssignments()
        test_assignment_manager.add_phone(test_phone)
        test_assignment_manager.add_employee(test_employee)

        test_assignment_manager.assign(1, test_employee)
        member_assigned = test_phone.employee_id

        self.assertIsNotNone(member_assigned)

        test_assignment_manager.un_assign(1)
        member_assigned = test_phone.employee_id

        self.assertIsNone(member_assigned)
コード例 #20
0
ファイル: test_phone_manager.py プロジェクト: abdiawali/week4
    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
        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)
        testAssignmentMgr.un_assign(testPhone1.id)

        #test it's none after unassign employee by checking phone's employee
        self.assertIsNone(testPhone1.employee_id)
コード例 #21
0
ファイル: main.py プロジェクト: pi6220na/SDCLab4
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
コード例 #22
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

        testUnAssign = Phone(1, 'PhoneName', 'PhoneModel')
        testEmployee = Employee(1, 'EmployeeName')
        # This adds the data to the PhoneAssignments()
        testUnAssignMgr = PhoneAssignments()

        # The phone gets assigned.
        testUnAssignMgr.assign(testUnAssign, testEmployee)
        # This asserts that the phone is un-assigned.
        self.assertTrue(self, testUnAssignMgr.un_assign(testUnAssign.id))
コード例 #23
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')
    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