def discrepancies_found_test(self): creation_date = now() - timedelta(hours=25) self.create_batch(VumiLogFactory, 5, direction=OUTGOING) self.create_batch(SMSFactory, 6, creation_date=creation_date, direction=OUTGOING, carrier=self.vumi_backend) audit_outgoing_sms() discrepancies = models.Discrepancy.objects.all() self.assertEqual(discrepancies.count(), 1)
def test_dont_find_message_tester_sms_objects(self): """SMS objects which don't go to Vumi should not be audited.""" # make sure the SMS objects are older than 24 hours, or else we don't audit them creation_date = now() - timedelta(hours=25) # create a message_tester SMS object which should not get audited test_backend = BackendFactory(name=settings.HTTPTESTER_BACKEND) SMSFactory(direction=OUTGOING, creation_date=creation_date, carrier=test_backend) # create an SMS object that SHOULD get audited audited_sms = SMSFactory(direction=OUTGOING, creation_date=creation_date, carrier=self.vumi_backend) audit_outgoing_sms() discrepancies = models.Discrepancy.objects.all() # only 1 discrepancy found self.assertEqual(discrepancies.count(), 1) self.assertEqual(discrepancies[0].trail.sms, audited_sms)