示例#1
0
 def setUp(self):
     self.user = factories.UserFactory(profile__acct_type='pro')
     self.user.profile.organization = factories.OrganizationFactory(
         active=True)
     self.foia = factories.FOIARequestFactory(user=self.user)
     self.request_factory = RequestFactory()
     self.url = self.foia.get_absolute_url()
示例#2
0
 def test_is_advanced(self):
     """Test whether the users are marked as advanced."""
     beta = factories.ProfileFactory(acct_type='beta')
     proxy = factories.ProfileFactory(acct_type='beta')
     admin = factories.ProfileFactory(acct_type='admin')
     basic = factories.ProfileFactory(acct_type='basic')
     active_org = factories.OrganizationFactory(active=True)
     inactive_org = factories.OrganizationFactory(active=False)
     active_org_member = factories.ProfileFactory(acct_type='basic', organization=active_org)
     inactive_org_member = factories.ProfileFactory(acct_type='basic', organization=inactive_org)
     assert_true(self.profile.is_advanced())
     assert_true(beta.is_advanced())
     assert_true(proxy.is_advanced())
     assert_true(admin.is_advanced())
     assert_true(active_org_member.is_advanced())
     assert_false(basic.is_advanced())
     assert_false(inactive_org_member.is_advanced())
示例#3
0
 def test_org_invoice_receipt(self, mock_send):
     """A receipt should be sent after an org subscription payment is made."""
     mock_subscription.plan.id = 'org'
     customer_id = 'test-org'
     owner = factories.UserFactory(profile__customer_id=customer_id)
     factories.OrganizationFactory(owner=owner)
     mock_invoice.customer = customer_id
     tasks.send_invoice_receipt(mock_invoice.id)
     mock_send.assert_called_with(fail_silently=False)
示例#4
0
 def test_last_attempt_org(self, mock_cancel, mock_send):
     """After the last attempt at payment, cancel the user's org subscription"""
     self.profile.payment_failed = True
     self.profile.save()
     ok_(self.profile.payment_failed,
         'The payment failed flag should be raised.')
     factories.OrganizationFactory(owner=self.profile.user)
     mock_invoice.attempt_count = 4
     mock_invoice.lines.data[0].plan.id = 'org'
     tasks.failed_payment(mock_invoice.id)
     self.profile.refresh_from_db()
     mock_cancel.assert_called_with()
     mock_send.assert_called_with(fail_silently=False)
     ok_(not self.profile.payment_failed,
         'The payment failed flag should be lowered.')
示例#5
0
 def setUp(self):
     self.agencies = factories.AgencyFactory.create_batch(6)
     self.organization = factories.OrganizationFactory(num_requests=100)
     self.multi = factories.FOIAMultiRequestFactory(
         status='submitted',
         agencies=self.agencies,
         num_org_requests=1,
         num_monthly_requests=2,
         num_reg_requests=3,
         user__profile__num_requests=5,
         user__profile__monthly_requests=10,
         user__profile__organization=self.organization,
     )
     self.task = task.models.MultiRequestTask.objects.create(
         multirequest=self.multi, )