当前位置: 首页>>代码示例>>Python>>正文


Python Employee.company方法代码示例

本文整理汇总了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')
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:29,代码来源:oldtests.py

示例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)
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:10,代码来源:oldtests.py

示例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)
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:22,代码来源:oldtests.py

示例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)
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:15,代码来源:oldtests.py


注:本文中的models.Employee.company方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。