def setUp(self): transaction.commit_on_success = mock.MagicMock() CompetenceFieldCollectionToUserRelation.save = mock.MagicMock() CompetenceFieldCollectionToUserRelation.objects.create = mock.MagicMock( ) CompetenceFieldCollectionToUserRelation.objects.create.return_value = CompetenceFieldCollectionToUserRelation( ) CompetenceFieldCollection.objects.get = mock.MagicMock() AssignmentKeyToUserRelation.objects.create = mock.MagicMock() AssignmentKeyToUserRelation.objects.create.return_value = AssignmentKeyToUserRelation( ) AssignmentKey.objects.all = mock.MagicMock() AssignmentKey.objects.all.return_value = [ AssignmentKey(), ] DevelopmentPlan.save = mock.MagicMock() self.employee = Employee() self.employee.pk = 7 self.employee.user = User() self.employee.user.pk = 32 self.employee.manager = Employee() self.employee.manager.pk = 76 self.employee.manager.user = User() self.employee.manager.user.pk = 99 self.current_user = self.employee.manager.user
def test_callingDevelopmentPlanStatusReturnsStringIfLastPlanIsOpen(self): CompetenceFieldCollectionToUserRelation.objects.filter.return_value.order_by.return_value = [ CompetenceFieldCollectionToUserRelation(user=self.employee.user, finished_at=None), ] CompetenceFieldCollectionToUserRelation.objects.filter.return_value.count.return_value = 1 self.assertEquals(u'Åben', self.employee.developmentPlanStatus()) CompetenceFieldCollectionToUserRelation.objects.filter.assert_called_with( user__pk=self.employee.user.pk) CompetenceFieldCollectionToUserRelation.objects.filter.return_value.order_by.assert_called_with( '-finished_at')
class CompetenceFieldCollectionToUserRelationTest(unittest.TestCase): def test_ExpectThatCompetenceFieldCollectionToUserRelationInstanceHasIsPrivateSetToTruByDefault( self): self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation( ) self.assertTrue( self.competence_field_collection_to_user_relation.is_private) def test_callingToggleIsPrivateInvertsTheIsPrivateProperty(self): self.assertTrue( self.competence_field_collection_to_user_relation.is_private) self.competence_field_collection_to_user_relation.toggleIsPrivate() self.assertFalse( self.competence_field_collection_to_user_relation.is_private) self.competence_field_collection_to_user_relation.toggleIsPrivate() self.assertTrue( self.competence_field_collection_to_user_relation.is_private) def test_callingToogleIsPrivateCallsSaveOnTheCompetenceFieldCollectionToUserRelation( self): self.competence_field_collection_to_user_relation.toggleIsPrivate() self.assertEquals( 1, CompetenceFieldCollectionToUserRelation.save.call_count) def setUp(self): CompetenceFieldCollectionToUserRelation.save = mock.MagicMock() self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation( )
def test_callingDevelopmentPlanStatusReturnsStringIfLastPlanIsClosed(self): dt = datetime.datetime.now() CompetenceFieldCollectionToUserRelation.objects.filter.return_value.order_by.return_value = [ CompetenceFieldCollectionToUserRelation(user=self.employee.user, finished_at=dt), ] CompetenceFieldCollectionToUserRelation.objects.filter.return_value.count.return_value = 1 self.assertEquals(dt.strftime(u'Lukket den %d. %B %Y'), self.employee.developmentPlanStatus()) CompetenceFieldCollectionToUserRelation.objects.filter.assert_called_with( user__pk=self.employee.user.pk) CompetenceFieldCollectionToUserRelation.objects.filter.return_value.order_by.assert_called_with( '-finished_at')
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)
class CompetenceFieldCollectionToUserRelationTest(unittest.TestCase): def test_ExpectThatCompetenceFieldCollectionToUserRelationInstanceHasIsPrivateSetToTruByDefault(self): self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation() self.assertTrue(self.competence_field_collection_to_user_relation.is_private) def test_callingToggleIsPrivateInvertsTheIsPrivateProperty(self): self.assertTrue(self.competence_field_collection_to_user_relation.is_private) self.competence_field_collection_to_user_relation.toggleIsPrivate() self.assertFalse(self.competence_field_collection_to_user_relation.is_private) self.competence_field_collection_to_user_relation.toggleIsPrivate() self.assertTrue(self.competence_field_collection_to_user_relation.is_private) def test_callingToogleIsPrivateCallsSaveOnTheCompetenceFieldCollectionToUserRelation(self): self.competence_field_collection_to_user_relation.toggleIsPrivate() self.assertEquals(1, CompetenceFieldCollectionToUserRelation.save.call_count) def setUp(self): CompetenceFieldCollectionToUserRelation.save = mock.MagicMock() self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation()
def setUp(self): CompetenceFieldCollectionToUserRelation.save = mock.MagicMock() self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation()
def test_ExpectThatCompetenceFieldCollectionToUserRelationInstanceHasIsPrivateSetToTruByDefault(self): self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation() self.assertTrue(self.competence_field_collection_to_user_relation.is_private)
def setUp(self): CompetenceFieldCollectionToUserRelation.save = mock.MagicMock() self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation( )
def test_ExpectThatCompetenceFieldCollectionToUserRelationInstanceHasIsPrivateSetToTruByDefault( self): self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation( ) self.assertTrue( self.competence_field_collection_to_user_relation.is_private)