コード例 #1
0
 def test_doesnt_show_nonlive_partners(self):
     county = models.County.objects.first()
     live_org = auth_models.Organization(
         name='Starfleet',
         slug='starfleet',
         county=county,
         is_receiving_agency=True,
         is_live=True,
     )
     not_live_org = auth_models.Organization(
         name="Jem'Hadar",
         slug='jem-hadar',
         county=county,
         is_receiving_agency=True,
         is_live=False,
     )
     live_org.save()
     not_live_org.save()
     with self.settings(ONLY_SHOW_LIVE_COUNTIES=True):
         response = self.client.get(reverse('intake-partner_list'))
         self.assertContains(
             response,
             html_utils.conditional_escape(live_org.get_absolute_url()))
         self.assertNotContains(
             response,
             html_utils.conditional_escape(not_live_org.get_absolute_url()))
コード例 #2
0
 def test_get_referral_emails_even_if_no_users(self):
     expected_email = "*****@*****.**"
     # we need an org
     org = models.Organization(name="Acme Nonprofit Services Inc.")
     org.save()
     user = mock.fake_superuser()
     models.Invitation.create(
         expected_email,
         organization=org,
         inviter=user)
     emails = org.get_referral_emails()
     self.assertListEqual(emails, [expected_email])
コード例 #3
0
    def test_shows_nonlive_partners_if_live_county_choices_is_false(self):
        county = models.County.objects.first()
        live_org = auth_models.Organization(
            name='Starfleet',
            slug='starfleet',
            county=county,
            is_receiving_agency=True,
            is_live=True,
        )
        not_live_org = auth_models.Organization(
            name="Jem'Hadar",
            slug='jem-hadar',
            county=county,
            is_receiving_agency=True,
            is_live=False,
        )
        live_org.save()
        not_live_org.save()

        with self.settings(ONLY_SHOW_LIVE_COUNTIES=False):
            response = self.client.get(reverse('intake-partner_list'))
            for org in [live_org, not_live_org]:
                self.assertContains(response,
                                    html_utils.conditional_escape(org.name))
コード例 #4
0
    def test_returns_orgs_iff_have_subs_and_profiles(self):
        expected_org = auth_models.Organization.objects.get(slug='a_pubdef')
        org_with_subs_but_no_user = auth_models.Organization.objects.get(
            slug='cc_pubdef')
        # delete user_profiles for coco
        auth_models.UserProfile.objects.filter(
            organization=org_with_subs_but_no_user).delete()
        org_with_users_but_no_subs = auth_models.Organization.objects.get(
            slug='san_diego_pubdef')
        org_without_users_or_subs = auth_models.Organization(
            name='New Org', slug='new_org', is_receiving_agency=True)
        org_without_users_or_subs.save()

        with self.assertNumQueries(1):
            org_results = set(
                BundlesService.get_orgs_that_might_need_a_bundle_email_today())

        self.assertIn(expected_org, org_results)
        self.assertNotIn(org_with_subs_but_no_user, org_results)
        self.assertNotIn(org_with_users_but_no_subs, org_results)
        self.assertNotIn(org_without_users_or_subs, org_results)
コード例 #5
0
 def test_get_referral_emails_raises_error_with_no_emails(self):
     org = models.Organization(name="Acme Nonprofit Services Inc.")
     org.save()
     with self.assertRaises(exceptions.NoEmailsForOrgError):
         org.get_referral_emails()