def test_should_return_none_if_no_responses_found(self): smc = create_group('SMC') location = create_location('kampala', create_location_type('district')) emisreporter = create_emis_reporters('reporter1', location, None, 12345, smc) latest_date = latest(emisreporter) self.assertEqual(None, latest_date)
def test_should_return_latest_reporting_date_for_record(self): smc = create_group('SMC') location = create_location('kampala', create_location_type('district')) emis_reporter = create_emis_reporters('reporter1',location,None,12345,smc) poll = create_poll_with_reporters('poll1','dummy question',Poll.TYPE_TEXT,create_user_with_group('user1'),[emis_reporter]) responses1 = Response.objects.create(poll=poll,contact=emis_reporter) responses2 = Response.objects.create(poll=poll,contact=emis_reporter) responses3 = Response.objects.create(poll=poll,contact=emis_reporter) self.set_response_date(responses1,dateutils.increment(datetime.now(),weeks=-1)) self.set_response_date(responses2,dateutils.increment(datetime.now(),weeks=-2)) self.set_response_date(responses3,dateutils.increment(datetime.now(),weeks=-3)) latest_date = latest(emis_reporter) self.assertEqual(dateutils.increment(datetime.now(),weeks=-1).date(),latest_date.date())
def test_should_return_latest_reporting_date_for_record(self): smc = create_group('SMC') location = create_location('kampala', create_location_type('district')) emis_reporter = create_emis_reporters('reporter1', location, None, 12345, smc) poll = create_poll_with_reporters('poll1', 'dummy question', Poll.TYPE_TEXT, create_user_with_group('user1'), [emis_reporter]) responses1 = Response.objects.create(poll=poll, contact=emis_reporter) responses2 = Response.objects.create(poll=poll, contact=emis_reporter) responses3 = Response.objects.create(poll=poll, contact=emis_reporter) self.set_response_date(responses1, dateutils.increment(datetime.now(), weeks=-1)) self.set_response_date(responses2, dateutils.increment(datetime.now(), weeks=-2)) self.set_response_date(responses3, dateutils.increment(datetime.now(), weeks=-3)) latest_date = latest(emis_reporter) self.assertEqual( dateutils.increment(datetime.now(), weeks=-1).date(), latest_date.date())
def test_should_return_none_if_no_responses_found(self): smc = create_group('SMC') location = create_location('kampala', create_location_type('district')) emisreporter = create_emis_reporters('reporter1',location,None,12345,smc) latest_date = latest(emisreporter) self.assertEqual(None,latest_date)