Esempio n. 1
0
 def test_broadcasts_by_date(self):
     "Filter broadcasts to a given month."
     today = datetime.datetime.now()
     last_month = today - datetime.timedelta(days=today.day + 1)
     self.create_broadcast_message(data={'recipient': self.test_staff, 'date_sent': last_month})
     self.create_broadcast_message(data={'recipient': self.test_staff})
     self.create_broadcast_message(data={'recipient': self.test_patient.contact})
     results = views.broadcast_stats(day=today)
     self.assertEqual(results['total'], 2)
     self.assertEqual(results['patients'], 1)
     self.assertEqual(results['staff'], 1)
     results = views.broadcast_stats(day=last_month)
     self.assertEqual(results['total'], 1)
     self.assertEqual(results['patients'], 0)
     self.assertEqual(results['staff'], 1)
Esempio n. 2
0
 def test_queued_messages(self):
     "Don't count messages which haven't been sent."
     self.create_broadcast_message(data={'recipient': self.test_staff, 'status': 'queued'})
     self.create_broadcast_message(data={'recipient': self.test_staff})
     self.create_broadcast_message(data={'recipient': self.test_patient.contact})
     results = views.broadcast_stats()
     self.assertEqual(results['total'], 2)
     self.assertEqual(results['patients'], 1)
     self.assertEqual(results['staff'], 1)
Esempio n. 3
0
 def test_coldchain_by_date(self):
     "Filter coldchain requests to a given month."
     today = datetime.datetime.now()
     last_month = today - datetime.timedelta(days=today.day + 1)
     broadcast = self.create_broadcast(data={'forward': self.coldchain, 'schedule_frequency': None})
     self.create_broadcast_message(data={
         'recipient': self.test_staff, 'broadcast': broadcast, 'date_sent': last_month
     })
     self.create_broadcast_message(data={'recipient': self.test_staff})
     results = views.broadcast_stats(day=today)
     self.assertEqual(results['total'], 1)
     self.assertEqual(results['patients'], 0)
     self.assertEqual(results['staff'], 1)
     self.assertEqual(results['coldchain'], 0)
     results = views.broadcast_stats(day=last_month)
     self.assertEqual(results['total'], 1)
     self.assertEqual(results['patients'], 0)
     self.assertEqual(results['staff'], 1)
     self.assertEqual(results['coldchain'], 1)
Esempio n. 4
0
 def test_all_broadcasts(self):
     "Current broadcast usage to date."
     self.create_broadcast_message(data={'recipient': self.test_staff})
     self.create_broadcast_message(data={'recipient': self.test_staff})
     self.create_broadcast_message(data={'recipient': self.test_patient.contact})
     results = views.broadcast_stats()
     self.assertEqual(results['total'], 3)
     self.assertEqual(results['patients'], 1)
     self.assertEqual(results['staff'], 2)
     self.assertEqual(results['callbacks'], 0)
     self.assertEqual(results['coldchain'], 0)
Esempio n. 5
0
 def test_all_coldchain(self):
     "Count cold chain forwards."
     # Cold chains are as one-time broadcasts which have null frequency once they are sent
     broadcast = self.create_broadcast(data={'forward': self.coldchain, 'schedule_frequency': None})
     self.create_broadcast_message(data={'recipient': self.test_staff, 'broadcast': broadcast})
     self.create_broadcast_message(data={'recipient': self.test_staff})
     self.create_broadcast_message(data={'recipient': self.test_patient.contact})
     results = views.broadcast_stats()
     self.assertEqual(results['total'], 3)
     self.assertEqual(results['patients'], 1)
     self.assertEqual(results['staff'], 2)
     self.assertEqual(results['callbacks'], 0)
     self.assertEqual(results['coldchain'], 1)