예제 #1
0
 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
예제 #2
0
 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')
예제 #3
0
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(
        )
예제 #4
0
 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')
예제 #5
0
 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)
예제 #6
0
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()
예제 #7
0
	def setUp(self):
		CompetenceFieldCollectionToUserRelation.save = mock.MagicMock()
		self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation()
예제 #8
0
	def test_ExpectThatCompetenceFieldCollectionToUserRelationInstanceHasIsPrivateSetToTruByDefault(self):
		self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation()
		self.assertTrue(self.competence_field_collection_to_user_relation.is_private)
예제 #9
0
 def setUp(self):
     CompetenceFieldCollectionToUserRelation.save = mock.MagicMock()
     self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation(
     )
예제 #10
0
 def test_ExpectThatCompetenceFieldCollectionToUserRelationInstanceHasIsPrivateSetToTruByDefault(
         self):
     self.competence_field_collection_to_user_relation = CompetenceFieldCollectionToUserRelation(
     )
     self.assertTrue(
         self.competence_field_collection_to_user_relation.is_private)