def test_doesnt_return_non_live_orgs(self): non_live_org = Organization(name="Vulcan High Council", is_receiving_agency=True) live_org = Organization(name="United Federation of Planets", is_live=True, is_receiving_agency=True) non_live_org.save() live_org.save() counties, orgs = CountiesService.get_live_counties_and_orgs() self.assertNotIn(non_live_org, orgs) self.assertIn(live_org, orgs)
def test_nonlive_application_doesnt_break_stats_page(self): self.be_monitor_user() non_live_org = Organization(name="Maquis", slug="maquis", is_receiving_agency=True, is_live=False, county=models.County.objects.first()) non_live_org.save() FormSubmissionWithOrgsFactory.create(organizations=[non_live_org], answers={}) response = self.client.get(reverse('intake-stats')) self.assertEqual(response.status_code, 200)
def test_doesnt_return_non_live_orgs(self): non_live_org = Organization( name="Vulcan High Council", is_receiving_agency=True) live_org = Organization( name="United Federation of Planets", is_live=True, is_receiving_agency=True) non_live_org.save() live_org.save() counties, orgs = CountiesService.get_live_counties_and_orgs() self.assertNotIn(non_live_org, orgs) self.assertIn(live_org, orgs)
def test_returns_counties_with_at_least_one_live_org(self): county = County.objects.first() non_live_org = Organization( name="Vulcan High Council", county=county, is_receiving_agency=True) live_org = Organization( name="United Federation of Planets", is_live=True, county=county, is_receiving_agency=True) non_live_org.save() live_org.save() counties, orgs = CountiesService.get_live_counties_and_orgs() self.assertIn(county, counties)
def test_returns_counties_with_at_least_one_live_org(self): county = County.objects.first() non_live_org = Organization(name="Vulcan High Council", county=county, is_receiving_agency=True) live_org = Organization(name="United Federation of Planets", is_live=True, county=county, is_receiving_agency=True) non_live_org.save() live_org.save() counties, orgs = CountiesService.get_live_counties_and_orgs() self.assertIn(county, counties)
def test_nonlive_application_doesnt_break_stats_page(self): self.be_monitor_user() non_live_org = Organization( name="Maquis", slug="maquis", is_receiving_agency=True, is_live=False, county=models.County.objects.first() ) non_live_org.save() FormSubmissionWithOrgsFactory.create( organizations=[non_live_org], answers={}) response = self.client.get(reverse('intake-stats')) self.assertEqual(response.status_code, 200)
def test_diff_dates_same_sub_no_change(self): # make sure that if the application times differ slightly, it does # not affect the count one_org = Organization(name="House Stark", slug='stark') one_org.save() other_org = Organization(name="House Tyrell", slug='tyrell') other_org.save() sub = FormSubmissionWithOrgsFactory( organizations=[one_org, other_org], answers={}) app = sub.applications.first() app.created = app.created + datetime.timedelta(milliseconds=1) app.save() results = statistics.rollup_subs( statistics.get_app_dates_sub_ids_org_ids()) self.assertEqual(len(results), 1)