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


Python Employee.user方法代码示例

本文整理汇总了Python中models.Employee.user方法的典型用法代码示例。如果您正苦于以下问题:Python Employee.user方法的具体用法?Python Employee.user怎么用?Python Employee.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Employee的用法示例。


在下文中一共展示了Employee.user方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_callingGetEmployeesReturnsListOfDicts

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [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_callingCanAssociateNewPlanReturnsFalseIfTheEmployeeHasAnOpenDevelopmentPlan

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [as 别名]
	def test_callingCanAssociateNewPlanReturnsFalseIfTheEmployeeHasAnOpenDevelopmentPlan(self):
		employee = Employee()
		employee.pk = 38
		employee.user = User()
		employee.user.pk = 9
		CompetenceFieldCollectionToUserRelation.objects.filter = mock.MagicMock()
		CompetenceFieldCollectionToUserRelation.objects.filter.return_value.exists = mock.MagicMock()
		CompetenceFieldCollectionToUserRelation.objects.filter.return_value.exists.return_value = [CompetenceFieldCollectionToUserRelation(employee.user, finished_at=None),]
		self.assertFalse(employee.canAssociateNewPlan())
		CompetenceFieldCollectionToUserRelation.objects.filter.assert_called_once_with(user__pk=employee.user.pk, finished_at=None)
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:12,代码来源:oldtests.py

示例3: test_callingGetDevelopmentPlansCallsFilterAndOrderByOnDevelopmentPlanWithGivenUserAsArgument

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [as 别名]
	def test_callingGetDevelopmentPlansCallsFilterAndOrderByOnDevelopmentPlanWithGivenUserAsArgument(self):
		employee = Employee()
		employee.pk = 38
		employee.user = User()
		employee.user.pk = 9
		DevelopmentPlan.objects.filter = mock.MagicMock()
		DevelopmentPlan.objects.filter.return_value.order_by = mock.MagicMock()
		employee.getDevelopmentPlans()
		DevelopmentPlan.objects.filter.assert_called_once_with(owner__pk=38)
		DevelopmentPlan.objects.filter.return_value.order_by.assert_called_once_with('-created_at')
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:12,代码来源:oldtests.py

示例4: test_callingGetEmployeesCallsGetMyEmployeesOneTimePerManagerInSameCompanyAsCaller

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [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

示例5: test_callingGetMyEmployeesCallsOrderByOnFilterResultWithLastNameThenFirstNameAsArguments

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [as 别名]
	def test_callingGetMyEmployeesCallsOrderByOnFilterResultWithLastNameThenFirstNameAsArguments(self):
		employee = Employee()
		employee.pk = 2
		with mock.patch.object(Employee, 'objects') as query_mock:
			return_employee = Employee()
			return_employee.pk = 4
			return_employee.user = User()
			return_employee.user.first_name = 'Joachim'
			return_employee.user.last_name = 'Andersen'
			return_employee.manager = employee
			employee.getMyEmployees()
			query_mock.filter.return_value.order_by.assert_called_with('user__last_name', 'user__first_name')
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:14,代码来源:oldtests.py

示例6: test_callingGetDevelopmentPlansReturnsListOfDevelopmentPlans

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [as 别名]
	def test_callingGetDevelopmentPlansReturnsListOfDevelopmentPlans(self):
		employee = Employee()
		employee.pk = 38
		employee.user = User()
		employee.user.pk = 9
		development_plan_one = DevelopmentPlan()
		development_plan_two = DevelopmentPlan()
		DevelopmentPlan.objects.filter = mock.MagicMock()
		DevelopmentPlan.objects.filter.return_value.order_by = mock.MagicMock()
		DevelopmentPlan.objects.filter.return_value.order_by.return_value = [development_plan_one, development_plan_two]
		development_plans = employee.getDevelopmentPlans()
		self.assertEquals(2, len(development_plans))
		self.assertTrue(isinstance(development_plans[0], DevelopmentPlan))
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:15,代码来源:oldtests.py

示例7: test_callingGetEmployeesCallsGetMyEmployeesWithEmployeeAsArgument

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [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

示例8: new_user

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [as 别名]
def new_user(request):
	use = User.objects.create_user(request.GET['username'],'',request.GET['pass'])
	use.last_name = request.GET['lname']
	use.first_name = request.GET['fname']
	use.save()
	new_date = datetime.date.today() - datetime.timedelta(days=1)
	e = Employee()
	e.user = use
	e.lastVoted = new_date
	e.save()
	user = authenticate(username=request.GET['username'],password=request.GET['pass'])
	login(request,user)
	return HttpResponseRedirect('/home/')
开发者ID:flexairconsultant,项目名称:gamereview,代码行数:15,代码来源:views.py

示例9: test_callingGetMyEmployeesReturnsListOfEmployees

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import user [as 别名]
	def test_callingGetMyEmployeesReturnsListOfEmployees(self):
		employee = Employee()
		employee.pk = 2
		with mock.patch.object(Employee, 'objects') as employee_mock:
			return_employee = Employee()
			return_employee.pk = 4
			return_employee.user = User()
			return_employee.user.first_name = 'Joachim'
			return_employee.user.last_name = 'Andersen'
			return_employee.manager = employee
			query_set_mock = mock.MagicMock()
			query_set_mock.order_by.return_value = iter([return_employee, ])
			employee_mock.filter.return_value = query_set_mock
			result = employee.getMyEmployees()
			self.assertTrue(isinstance(result[0], Employee))
			self.assertEqual(1, len(result))
			self.assertEqual(4, result[0].pk)
			self.assertEqual('Joachim', result[0].user.first_name)
			self.assertEqual('Andersen', result[0].user.last_name)
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:21,代码来源:oldtests.py


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