Exemple #1
0
 def test_save_pending_calls_send_email(self):
     with mock.patch('timepiece.contracts.models.ContractHour._send_mail'
                     ) as send_mail:
         factories.ContractHour(status=ContractHour.PENDING_STATUS)
     self.assertTrue(send_mail.called)
     (subject, ctx) = send_mail.call_args[0]
     self.assertTrue(subject.startswith("New"))
Exemple #2
0
 def test_default_date_approved(self):
     # If saved with status approved and no date approved,
     # it sets it to today
     ch = factories.ContractHour(status=ContractHour.APPROVED_STATUS,
                                 date_approved=None)
     ch = ContractHour.objects.get(pk=ch.pk)
     self.assertEqual(datetime.date.today(), ch.date_approved)
Exemple #3
0
 def test_pending_hours(self):
     # If we create some pending Contract Hour objects and then go to the
     # project contract and get pending_hours(), it gives the sum
     # of the hours
     pc = factories.ProjectContract(contract_hours=4)
     ch = factories.ContractHour(contract=pc,
                                 hours=27,
                                 status=ContractHour.PENDING_STATUS)
     self.assertEqual(4, pc.contracted_hours())
     self.assertEqual(27, pc.pending_hours())
     ch.delete()
     self.assertEqual(4, pc.contracted_hours())
     self.assertEqual(0, pc.pending_hours())
Exemple #4
0
 def test_save_approved_does_not_call_send_email(self):
     with mock.patch('timepiece.contracts.models.ContractHour._send_mail'
                     ) as send_mail:
         factories.ContractHour(status=ContractHour.APPROVED_STATUS)
     self.assertFalse(send_mail.called)
Exemple #5
0
 def test_validation(self):
     with self.assertRaises(ValidationError):
         ch = factories.ContractHour(status=ContractHour.PENDING_STATUS,
                                     date_approved=datetime.date.today())
         ch.clean()