本文整理汇总了Python中models.Employee.company方法的典型用法代码示例。如果您正苦于以下问题:Python Employee.company方法的具体用法?Python Employee.company怎么用?Python Employee.company使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Employee
的用法示例。
在下文中一共展示了Employee.company方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_callingGetEmployeesReturnsListOfDicts
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import company [as 别名]
def test_callingGetEmployeesReturnsListOfDicts(self):
Employee.objects.filter = mock.MagicMock()
company = Company()
company.pk = 98
employee_one = Employee()
employee_one.pk = 12
employee_one.user = User()
employee_one.user.first_name = 'Fornavn'
employee_one.user.last_name = 'Efternavn'
employee_one.company = company
employee_two = Employee()
employee_two.pk = 13
employee_two.user = User()
employee_two.user.first_name = 'Fornavn'
employee_two.user.last_name = 'Efternavn'
employee_two.company = company
Employee.objects.filter.return_value = [employee_one, employee_two]
employee_one.getMyEmployees = mock.MagicMock()
employee_one.getMyEmployees.return_value = []
employee_list = employee_one.getEmployees()
self.assertEquals(2, len(employee_list))
self.assertTrue(isinstance(employee_list[0], dict))
self.assertTrue(isinstance(employee_list[0]['manager'], Employee))
self.assertEquals(employee_list[0]['manager'].pk, 12)
self.assertTrue(isinstance(employee_list[0]['employees'], list))
self.assertEquals(employee_list[0]['manager'].user.first_name, 'Fornavn')
self.assertEquals(employee_list[0]['manager'].user.last_name, 'Efternavn')
示例2: test_callingGetEmployeesCallsFilterOnEmployeeWithCompanyPkAsArgumentAndIsMangerEqualToTrue
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import company [as 别名]
def test_callingGetEmployeesCallsFilterOnEmployeeWithCompanyPkAsArgumentAndIsMangerEqualToTrue(self):
employee = Employee()
company = Company()
company.pk = 8
employee.company = company
with mock.patch.object(Employee, 'objects') as query_mock:
employee.getEmployees()
query_mock.filter.assert_called_with(company__pk=company.pk, is_manager=True)
示例3: test_callingGetEmployeesCallsGetMyEmployeesOneTimePerManagerInSameCompanyAsCaller
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import company [as 别名]
def test_callingGetEmployeesCallsGetMyEmployeesOneTimePerManagerInSameCompanyAsCaller(self):
Employee.objects.filter = mock.MagicMock()
company = Company()
company.pk = 98
employee_one = Employee()
employee_one.pk = 12
employee_one.company = company
employee_one.user = User()
employee_one.user.first_name = 'Fornavn'
employee_one.user.last_name = 'Efternavn'
employee_two = Employee()
employee_two.pk = 12
employee_two.company = company
employee_two.user = User()
employee_two.user.first_name = 'Fornavn'
employee_two.user.last_name = 'Efternavn'
Employee.objects.filter.return_value = [employee_one, employee_two]
employee_one.getMyEmployees = mock.MagicMock()
employee_one.getEmployees()
self.assertEquals(2, employee_one.getMyEmployees.call_count)
示例4: test_callingGetEmployeesCallsGetMyEmployeesWithEmployeeAsArgument
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import company [as 别名]
def test_callingGetEmployeesCallsGetMyEmployeesWithEmployeeAsArgument(self):
Employee.objects.filter = mock.MagicMock()
employee = Employee()
employee.pk = 29
employee.company = Company()
employee.company.pk = 87
employee.user = User()
employee.user.first_name = 'Fornavn'
employee.user.last_name = 'Efternavn'
Employee.objects.filter.return_value = [employee, ]
employee.getMyEmployees = mock.MagicMock()
employee.getEmployees()
employee.getMyEmployees.assert_called_once_with(manager=employee)