def test_calc_return_requests(self): """Test calculating the return requests""" composer = FOIAComposerFactory( status='submitted', agencies=AgencyFactory.create_batch(6), 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=OrganizationFactory(num_requests=100), ) values = [ (7, 4, 2, 1), (6, 3, 2, 1), (5, 3, 2, 0), (4, 3, 1, 0), (3, 3, 0, 0), (2, 2, 0, 0), (1, 1, 0, 0), ] for total, reg, monthly, org in values: eq_( composer._calc_return_requests(total), { 'regular': reg, 'monthly': monthly, 'org': org, }, )
def setUp(self): self.agencies = AgencyFactory.create_batch(6) self.organization = OrganizationFactory(num_requests=100) self.composer = FOIAComposerFactory( 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 = MultiRequestTask.objects.create(composer=self.composer)
def test_boilerplate(self): """Test the boilerplate ajax view""" agencies = AgencyFactory.create_batch(2) request = RequestFactory().get( reverse("agency-boilerplate"), {"agencies": [a.pk for a in agencies]} ) request = mock_middleware(request) request.user = UserFactory(profile__full_name="John Doe") response = boilerplate(request) eq_(response.status_code, 200) data = json.loads(response.content) assert_in("{ law name }", data["intro"]) assert_in("{ days }", data["outro"]) assert_in("John Doe", data["outro"])
def test_calc_return_requests(self): """Test calculating the return requests""" composer = FOIAComposerFactory( status="submitted", agencies=AgencyFactory.create_batch(6), num_monthly_requests=2, num_reg_requests=3, ) values = [(6, 4, 2), (5, 3, 2), (4, 3, 1), (3, 3, 0), (2, 2, 0), (1, 1, 0)] for total, reg, monthly in values: eq_( composer._calc_return_requests(total), {"regular": reg, "monthly": monthly}, )
def setUp(self): self.agencies = AgencyFactory.create_batch(6) self.composer = FOIAComposerFactory( status="submitted", agencies=self.agencies, num_monthly_requests=2, num_reg_requests=3, ) self.task = MultiRequestTask.objects.create(composer=self.composer) self.mocker = requests_mock.Mocker() mock_squarelet(self.mocker) self.mocker.start() self.addCleanup(self.mocker.stop)
def test_boilerplate(self): """Test the boilerplate ajax view""" agencies = AgencyFactory.create_batch(2) request = RequestFactory().get( reverse('agency-boilerplate'), { 'agencies': [a.pk for a in agencies], }, ) request = mock_middleware(request) request.user = UserFactory(first_name='John', last_name='Doe') response = boilerplate(request) eq_(response.status_code, 200) data = json.loads(response.content) assert_in('{ law name }', data['intro']) assert_in('{ days }', data['outro']) assert_in('John Doe', data['outro'])
def test_multi_agency(self): """Test with multiple agencies""" agencies = AgencyFactory.create_batch(3) response = self.api_call({"agency": [a.pk for a in agencies]}) eq_(len(response.json()["Requests"]), 3)
def test_multi_agency(self): """Test with multiple agencies""" agencies = AgencyFactory.create_batch(3) self.api_call({'agency': [a.pk for a in agencies]})