def test_callingGetDevelopmentPlansWithAsManagerEqualToTrueCallsFilterWithOwnerManagerAsArgument(self): employee = Employee() employee.pk = 38 DevelopmentPlan.objects.filter = mock.MagicMock() DevelopmentPlan.objects.filter.return_value.order_by = mock.MagicMock() employee.getDevelopmentPlans(as_manager=True) DevelopmentPlan.objects.filter.assert_called_once_with(owner__manager__pk=38)
def test_callingGetDevelopmentPlansWithAsManagerEqualToTrueCallsFilterWithOwnerManagerAsArgument( self): employee = Employee() employee.pk = 38 DevelopmentPlan.objects.filter = mock.MagicMock() DevelopmentPlan.objects.filter.return_value.order_by = mock.MagicMock() employee.getDevelopmentPlans(as_manager=True) DevelopmentPlan.objects.filter.assert_called_once_with( owner__manager__pk=38)
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')
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')
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))
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))