def test_find_employee(self, mock_stdout): employee_menu = EmployeeMenu() employee_username = "******" with mock.patch('builtins.input', side_effect=[employee_username, 'q', 'q', 'q']): employee_menu.search_employees() self.assertEqual(len(employee_menu.employees), 1)
def test_delete_employee_with_task(self, mock_stdout): employee_menu = EmployeeMenu() employee = Employee.get(employee_username="******") with mock.patch('builtins.input', side_effect=['y', 'q']): deleted_successfully = employee_menu.delete_entry(employee) self.assertFalse(deleted_successfully)
def test_add_existing_employee(self, mock_stdout): employee_menu = EmployeeMenu() employee_name = "Ron John" employee_username = "******" with mock.patch('builtins.input', side_effect=[employee_username, employee_name, 'q']): added_successfully = employee_menu.add_employee() self.assertFalse(added_successfully)
def test_add_employee(self, mock_stdout): employee_menu = EmployeeMenu() employee_username = "******" employee_name = "Jack Black" with mock.patch('builtins.input', side_effect=[employee_username, employee_name, 'q']): employee_menu.add_employee() found_employee = Employee.get(employee_username=employee_username) self.assertEqual(found_employee.employee_username, employee_username) self.assertEqual(found_employee.employee_name, employee_name)
def test_delete_employee(self, mock_stdout): employee_username = "******" employee_name = "Jane Smith" new_employee = Employee.create(employee_username=employee_username, employee_name=employee_name) new_employee.save() employee_menu = EmployeeMenu() found_employee = Employee.get(employee_username=employee_username) with mock.patch('builtins.input', side_effect=['y', 'q']): employee_menu.delete_entry(found_employee) with self.assertRaises(DoesNotExist): Employee.get(employee_username=employee_username)
def test_view_employees(self, mock_stdout): employee_name2 = "Ron John" employee_username2 = "rjohn" employee_username1 = "jblack" employee_name1 = "Jack Black" employee_menu = EmployeeMenu() with mock.patch('builtins.input', side_effect=['q', 'n', 'q']): employee_menu.view_employees() self.assertEqual(len(employee_menu.employees), 2) employee = employee_menu.employees[0] self.assertEqual(employee.employee_name, employee_name1) self.assertEqual(employee.employee_username, employee_username1) employee = employee_menu.employees[1] self.assertEqual(employee.employee_name, employee_name2) self.assertEqual(employee.employee_username, employee_username2)
def employee_management(self): """Employee Managment""" employee_menu = EmployeeMenu() employee_menu.menu_loop()