Example #1
0
    def test_dynamic_contacts_report(self):
        """Create some test data, run, list, and download a contacts report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            # unicode here to push through report generation/download
            ContactFactory.create(name=u"name-%s \u2019" % i, partner=partner)

        report_data = self.find_report_data("contacts")

        resp = self.client.post(
            reverse("run_dynamic_report"), data={"report_data_id": report_data.pk, "name": "The Report"}
        )
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)["id"]

        resp = self.client.get(reverse("list_dynamic_reports"))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {"reports": [{"id": report_id, "name": "The Report", "report_type": "contacts"}]}, json.loads(resp.content)
        )

        report_presentation = self.find_report_presentation(report_data, "json_pass")

        data = {"id": report_id, "report_presentation_id": report_presentation.pk}
        resp = self.client.get(reverse("download_dynamic_report"), data)
        self.assertEquals(200, resp.status_code)

        response_data = json.loads(resp.content)
        self.assertEquals(10, len(response_data["records"]))

        first_found_name = response_data["records"][0]["Name"]
        expected_name = u"name-0 \u2019"
        self.assertEqual(expected_name, first_found_name)
Example #2
0
    def test_filtered_report(self):
        """Run a dynamic report with a filter."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(
                city="city-%s" % i)
            ContactFactory.create(
                name="name-%s" % i,
                partner=partner,
                locations=[location])

        report_data = (
            self.dynamic_models['report_type/data_type']
            ['contacts/unaggregated'])
        report = DynamicReport.objects.create(
            report_data=report_data,
            filters=json.dumps({
                'locations': {
                    'city': 'city-2',
                },
            }),
            owner=self.company)
        report.regenerate()
        expected_column_names = {
            'name', 'tags', 'notes', 'locations', 'phone', 'partner',
            'email', 'date'}
        self.assertEqual(1, len(report.python))
        self.assertEqual('name-2', report.python[0]['name'])
        self.assertEqual(expected_column_names, set(report.python[0]))
Example #3
0
    def test_dynamic_report_with_filter(self):
        """Create some test data, run filtered, and download a report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(city="city-%s" % i)
            ContactFactory.create(name="name-%s" % i, partner=partner, locations=[location])

        report_data = self.find_report_data("contacts")

        resp = self.client.post(
            reverse("run_dynamic_report"),
            data={
                "report_data_id": report_data.pk,
                "name": "The Report",
                "filter": json.dumps({"locations": {"city": "city-2"}}),
            },
        )
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)["id"]

        report_presentation = self.find_report_presentation(report_data, "json_pass")

        data = {"id": report_id, "report_presentation_id": report_presentation.pk}
        resp = self.client.get(reverse("download_dynamic_report"), data)
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(1, len(response_data["records"]))

        found_name = response_data["records"][0]["Name"]
        expected_name = u"name-2"
        self.assertEqual(expected_name, found_name)
Example #4
0
    def test_dynamic_contacts_trial_report(self):
        """Run a trial report."""
        self.maxDiff = 10000
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(city="city-%s" % i, state="ZZ")
            # unicode here to push through report generation/download
            ContactFactory.create(name=u"name-%s \u2019" % i, partner=partner, locations=[location])

        report_data = self.find_report_data("contacts")

        resp = self.client.post(
            reverse("run_trial_dynamic_report"),
            data={
                "report_data_id": report_data.pk,
                "name": "The Report",
                "filter": json.dumps({"locations": {"city": "city-2"}}),
                "values": json.dumps(["phone", "tags", "email", "name"]),
            },
        )
        self.assertEqual(200, resp.status_code)
        report_content = json.loads(resp.content)
        self.assertEqual(
            [{u"email": u"*****@*****.**", u"name": u"name-2 \u2019", u"phone": u"84104391", u"tags": []}],
            report_content,
        )
Example #5
0
    def test_filtered_report(self):
        """Run a dynamic report with a filter."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(city="city-%s" % i)
            ContactFactory.create(name="name-%s" % i,
                                  partner=partner,
                                  locations=[location])

        report_data = (self.dynamic_models['report_type/data_type']
                       ['contacts/unaggregated'])
        report = DynamicReport.objects.create(report_data=report_data,
                                              filters=json.dumps({
                                                  'locations': {
                                                      'city': 'city-2',
                                                  },
                                              }),
                                              owner=self.company)
        report.regenerate()
        expected_column_names = {
            'name', 'tags', 'notes', 'locations', 'phone', 'partner', 'email',
            'date'
        }
        self.assertEqual(1, len(report.python))
        self.assertEqual('name-2', report.python[0]['name'])
        self.assertEqual(expected_column_names, set(report.python[0]))
Example #6
0
 def setUp(self):
     super(TestReportsApi, self).setUp()
     ContactFactory.create(
         name="a", email="*****@*****.**",
         partner=self.partner,
         locations=[
             LocationFactory.create(
                 city="Chicago",
                 state="IL"),
             LocationFactory.create(
                 city="Champaign",
                 state="IL"),
             ])
Example #7
0
    def test_dynamic_contacts_report(self):
        """Create some test data, run, list, and download a contacts report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            # unicode here to push through report generation/download
            ContactFactory.create(name=u"name-%s \u2019" % i, partner=partner)

        report_data = self.find_report_data('contacts')

        resp = self.client.post(reverse('run_dynamic_report'),
                                data={
                                    'report_data_id': report_data.pk,
                                    'name': 'The Report',
                                })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('list_dynamic_reports'))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {
                'reports': [
                    {
                        'id': report_id,
                        'name': 'The Report',
                        'report_type': 'contacts'
                    },
                ]
            }, json.loads(resp.content))

        report_presentation = self.find_report_presentation(
            report_data, 'json_pass')

        data = {
            'id': report_id,
            'report_presentation_id': report_presentation.pk,
        }
        resp = self.client.get(reverse('download_dynamic_report'), data)
        self.assertEquals(200, resp.status_code)

        response_data = json.loads(resp.content)
        self.assertEquals(10, len(response_data['records']))

        first_found_name = response_data['records'][0]['Name']
        expected_name = u'name-0 \u2019'
        self.assertEqual(expected_name, first_found_name)
Example #8
0
    def test_report(self):
        """Run a dynamic report through its paces."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            ContactFactory.create(name="name-%s" % i, partner=partner)

        report_pres = ReportPresentation.objects.get(id=3)
        report = DynamicReport.objects.create(
            report_presentation=report_pres,
            owner=self.company)
        report.regenerate()
        expected_column_names = set([
            'name', 'tags', 'notes', 'locations', 'phone', 'partner',
            'email'])
        self.assertEqual(10, len(report.python))
        self.assertEqual(expected_column_names, set(report.python[0]))
Example #9
0
    def test_dynamic_partners_report_comm_per_month(self):
        """Run the comm_rec per month per partner report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        partner.tags.add(TagFactory.create(name="this"))
        contact = ContactFactory.create(name='somename', partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(partner=partner,
                                 contact=contact,
                                 date_time=datetime(2015, 2, 4),
                                 subject=u"subject-%s \u2019" % i)

        report_data = self.find_report_data(
            'partners', data_type="count_comm_rec_per_month")

        resp = self.client.post(reverse('run_dynamic_report'),
                                data={
                                    'report_data_id': report_data.pk,
                                    'name': 'The Report',
                                    'filter': json.dumps({
                                        'tags': [['this']],
                                    }),
                                })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('list_dynamic_reports'))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {
                'reports': [
                    {
                        'id': report_id,
                        'name': 'The Report',
                        'report_type': 'partners'
                    },
                ]
            }, json.loads(resp.content))

        report_presentation = self.find_report_presentation(
            report_data, 'json_pass')

        data = {
            'id': report_id,
            'report_presentation_id': report_presentation.pk,
        }
        resp = self.client.get(reverse('download_dynamic_report'), data)
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(12, len(response_data['records']))
        january = response_data['records'][0]
        self.assertEqual('1', january['Month'])
        self.assertEqual('0', january['Communication Record Count'])
        february = response_data['records'][1]
        self.assertEqual('2', february['Month'])
        self.assertEqual('20', february['Communication Record Count'])
Example #10
0
    def test_report(self):
        """Run a dynamic report through its paces."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            ContactFactory.create(name="name-%s" % i, partner=partner)

        report_data = (self.dynamic_models['report_type/data_type']
                       ['contacts/unaggregated'])
        report = DynamicReport.objects.create(report_data=report_data,
                                              owner=self.company)
        report.regenerate()
        expected_column_names = {
            'name', 'tags', 'notes', 'locations', 'phone', 'partner', 'email',
            'date'
        }
        self.assertEqual(10, len(report.python))
        self.assertEqual(expected_column_names, set(report.python[0]))
Example #11
0
    def test_report(self):
        """Run a dynamic report through its paces."""
        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            ContactFactory.create(name="name-%s" % i, partner=partner)

        report_data = (
            self.dynamic_models['report_type/data_type']
            ['contacts/unaggregated'])
        report = DynamicReport.objects.create(
            report_data=report_data,
            owner=self.company)
        report.regenerate()
        expected_column_names = {
            'name', 'tags', 'notes', 'locations', 'phone', 'partner',
            'email', 'date'}
        self.assertEqual(10, len(report.python))
        self.assertEqual(expected_column_names, set(report.python[0]))
Example #12
0
    def test_dynamic_report_with_filter(self):
        """Create some test data, run filtered, and download a report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(city="city-%s" % i)
            ContactFactory.create(name="name-%s" % i,
                                  partner=partner,
                                  locations=[location])

        report_data = self.find_report_data('contacts')

        resp = self.client.post(reverse('run_dynamic_report'),
                                data={
                                    'report_data_id':
                                    report_data.pk,
                                    'name':
                                    'The Report',
                                    'filter':
                                    json.dumps({
                                        'locations': {
                                            'city': 'city-2',
                                        },
                                    }),
                                })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        report_presentation = self.find_report_presentation(
            report_data, 'json_pass')

        data = {
            'id': report_id,
            'report_presentation_id': report_presentation.pk,
        }
        resp = self.client.get(reverse('download_dynamic_report'), data)
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(1, len(response_data['records']))

        found_name = response_data['records'][0]['Name']
        expected_name = u'name-2'
        self.assertEqual(expected_name, found_name)
Example #13
0
    def test_dynamic_contacts_report(self):
        """Create some test data, run, list, and download a contacts report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            # unicode here to push through report generation/download
            ContactFactory.create(
                name=u"name-%s \u2019" % i,
                partner=partner)

        report_presentation = self.find_report_presentation(
            'contacts',
            'json_pass')

        resp = self.client.post(
            reverse('run_dynamic_report'),
            data={
                'rp_id': report_presentation.pk,
                'name': 'The Report',
            })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('list_dynamic_reports'))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {'reports': [
                {'id': report_id, 'name': 'The Report'},
            ]},
            json.loads(resp.content))

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)

        response_data = json.loads(resp.content)
        self.assertEquals(10, len(response_data['records']))

        first_found_name = response_data['records'][0]['name']
        expected_name = u'name-0 \u2019'
        self.assertEqual(expected_name, first_found_name)
Example #14
0
    def test_dynamic_report(self):
        """Create some test data, run, and download a report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            ContactFactory.create(name=u"name-%s \u2019" % i, partner=partner)

        resp = self.client.post(reverse('run_dynamic_report'), {'rp_id': 3})
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)
        lines = resp.content.splitlines()
        first_found_name = lines[1].split(',')[0]
        expected_name = u'name-0 \u2019'.encode('utf-8')
        self.assertEqual(expected_name, first_found_name)
        self.assertEquals(11, len(lines))
Example #15
0
    def test_dynamic_contacts_trial_report(self):
        """Run a trial report."""
        self.maxDiff = 10000
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(city="city-%s" % i, state='ZZ')
            # unicode here to push through report generation/download
            ContactFactory.create(name=u"name-%s \u2019" % i,
                                  partner=partner,
                                  locations=[location])

        report_data = self.find_report_data('contacts')

        resp = self.client.post(reverse('run_trial_dynamic_report'),
                                data={
                                    'report_data_id':
                                    report_data.pk,
                                    'name':
                                    'The Report',
                                    'filter':
                                    json.dumps({
                                        'locations': {
                                            'city': 'city-2',
                                        },
                                    }),
                                    'values':
                                    json.dumps(
                                        ['phone', 'tags', 'email', 'name']),
                                })
        self.assertEqual(200, resp.status_code)
        report_content = json.loads(resp.content)
        self.assertEqual([
            {
                u'email': u'*****@*****.**',
                u'name': u'name-2 \u2019',
                u'phone': u'84104391',
                u'tags': [],
            },
        ], report_content)
Example #16
0
    def test_dynamic_report_with_filter(self):
        """Create some test data, run filtered, and download a report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        for i in range(0, 10):
            location = LocationFactory.create(
                city="city-%s" % i)
            ContactFactory.create(
                name="name-%s" % i,
                partner=partner,
                locations=[location])

        report_presentation = self.find_report_presentation(
            'contacts',
            'json_pass')

        resp = self.client.post(
            reverse('run_dynamic_report'),
            data={
                'rp_id': report_presentation.pk,
                'name': 'The Report',
                'filter': json.dumps({
                    'locations': {
                        'city': 'city-2',
                    },
                }),
            })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(1, len(response_data['records']))

        found_name = response_data['records'][0]['name']
        expected_name = u'name-2'
        self.assertEqual(expected_name, found_name)
Example #17
0
    def test_dynamic_partners_report_comm_per_month(self):
        """Run the comm_rec per month per partner report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        partner.tags.add(TagFactory.create(name="this"))
        contact = ContactFactory.create(name='somename', partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(
                partner=partner,
                contact=contact,
                date_time=datetime(2015, 2, 4),
                subject=u"subject-%s \u2019" % i)

        report_presentation = self.find_report_presentation(
            'partners',
            'json_pass',
            data_type="count_comm_rec_per_month")

        resp = self.client.post(
            reverse('run_dynamic_report'),
            data={
                'rp_id': report_presentation.pk,
                'name': 'The Report',
                'filter': json.dumps({
                    'tags': [['this']],
                }),
            })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('list_dynamic_reports'))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {'reports': [
                {'id': report_id, 'name': 'The Report'},
            ]},
            json.loads(resp.content))

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(12, len(response_data['records']))
        january = response_data['records'][0]
        self.assertEqual('1', january['month'])
        self.assertEqual('0', january['comm_rec_count'])
        february = response_data['records'][1]
        self.assertEqual('2', february['month'])
        self.assertEqual('20', february['comm_rec_count'])
Example #18
0
    def test_dynamic_comm_records_report(self):
        """Create some test data, run, list, and download a commrec report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        contact = ContactFactory.create(name='somename', partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(partner=partner,
                                 contact=contact,
                                 subject=u"subject-%s \u2019" % i)

        report_data = self.find_report_data('comm_records')

        resp = self.client.post(reverse('run_dynamic_report'),
                                data={
                                    'report_data_id': report_data.pk,
                                    'name': 'The Report',
                                })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('list_dynamic_reports'))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {
                'reports': [
                    {
                        'id': report_id,
                        'name': 'The Report',
                        'report_type': 'communication-records'
                    },
                ]
            }, json.loads(resp.content))

        report_presentation = self.find_report_presentation(
            report_data, 'json_pass')

        data = {
            'id': report_id,
            'report_presentation_id': report_presentation.pk,
        }
        resp = self.client.get(reverse('download_dynamic_report'), data)
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(20, len(response_data['records']))

        last_subject = response_data['records'][-1]['Subject']
        expected_subject = u'subject-19 \u2019'
        self.assertEqual(expected_subject, last_subject)
Example #19
0
    def setUp(self):
        super(TestReportsApi, self).setUp()
        contact = ContactFactory.create(
            name="a",
            email="*****@*****.**",
            partner=self.partner,
            locations=[
                LocationFactory.create(city="Chicago", state="IL"),
                LocationFactory.create(city="Champaign", state="IL"),
            ])

        contact.tags.add(TagFactory.create(name="Disability"))
        contact.tags.add(TagFactory.create(name="Veteran"))
        contact.tags.add(TagFactory.create(name="Senior"))
Example #20
0
    def setUp(self):
        super(TestReportsApi, self).setUp()
        contact = ContactFactory.create(
            name="a",
            email="*****@*****.**",
            partner=self.partner,
            locations=[
                LocationFactory.create(city="Chicago", state="IL"),
                LocationFactory.create(city="Champaign", state="IL"),
            ],
        )

        contact.tags.add(TagFactory.create(name="Disability"))
        contact.tags.add(TagFactory.create(name="Veteran"))
        contact.tags.add(TagFactory.create(name="Senior"))
Example #21
0
    def test_dynamic_comm_records_report(self):
        """Create some test data, run, list, and download a commrec report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        contact = ContactFactory.create(name='somename', partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(
                partner=partner,
                contact=contact,
                subject=u"subject-%s \u2019" % i)

        report_presentation = self.find_report_presentation(
            'comm_records',
            'json_pass')

        resp = self.client.post(
            reverse('run_dynamic_report'),
            data={
                'rp_id': report_presentation.pk,
                'name': 'The Report',
            })
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)['id']

        resp = self.client.get(reverse('list_dynamic_reports'))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {'reports': [
                {'id': report_id, 'name': 'The Report'},
            ]},
            json.loads(resp.content))

        resp = self.client.get(reverse('download_dynamic_report'),
                               {'id': report_id})
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(20, len(response_data['records']))

        last_subject = response_data['records'][-1]['subject']
        expected_subject = u'subject-19 \u2019'
        self.assertEqual(expected_subject, last_subject)
Example #22
0
    def test_dynamic_partners_report_comm_per_month(self):
        """Run the comm_rec per month per partner report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        partner.tags.add(TagFactory.create(name="this"))
        contact = ContactFactory.create(name="somename", partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(
                partner=partner, contact=contact, date_time=datetime(2015, 2, 4), subject=u"subject-%s \u2019" % i
            )

        report_data = self.find_report_data("partners", data_type="count_comm_rec_per_month")

        resp = self.client.post(
            reverse("run_dynamic_report"),
            data={"report_data_id": report_data.pk, "name": "The Report", "filter": json.dumps({"tags": [["this"]]})},
        )
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)["id"]

        resp = self.client.get(reverse("list_dynamic_reports"))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {"reports": [{"id": report_id, "name": "The Report", "report_type": "partners"}]}, json.loads(resp.content)
        )

        report_presentation = self.find_report_presentation(report_data, "json_pass")

        data = {"id": report_id, "report_presentation_id": report_presentation.pk}
        resp = self.client.get(reverse("download_dynamic_report"), data)
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(12, len(response_data["records"]))
        january = response_data["records"][0]
        self.assertEqual("1", january["Month"])
        self.assertEqual("0", january["Communication Record Count"])
        february = response_data["records"][1]
        self.assertEqual("2", february["Month"])
        self.assertEqual("20", february["Communication Record Count"])
Example #23
0
    def test_dynamic_comm_records_report(self):
        """Create some test data, run, list, and download a commrec report."""
        self.client.login_user(self.user)

        partner = PartnerFactory(owner=self.company)
        contact = ContactFactory.create(name="somename", partner=partner)

        for i in range(0, 20):
            # unicode here to push through report generation/download
            ContactRecordFactory(partner=partner, contact=contact, subject=u"subject-%s \u2019" % i)

        report_data = self.find_report_data("comm_records")

        resp = self.client.post(
            reverse("run_dynamic_report"), data={"report_data_id": report_data.pk, "name": "The Report"}
        )
        self.assertEqual(200, resp.status_code)
        report_id = json.loads(resp.content)["id"]

        resp = self.client.get(reverse("list_dynamic_reports"))
        self.assertEqual(200, resp.status_code)
        self.assertEqual(
            {"reports": [{"id": report_id, "name": "The Report", "report_type": "communication-records"}]},
            json.loads(resp.content),
        )

        report_presentation = self.find_report_presentation(report_data, "json_pass")

        data = {"id": report_id, "report_presentation_id": report_presentation.pk}
        resp = self.client.get(reverse("download_dynamic_report"), data)
        self.assertEquals(200, resp.status_code)
        response_data = json.loads(resp.content)
        self.assertEquals(20, len(response_data["records"]))

        last_subject = response_data["records"][-1]["Subject"]
        expected_subject = u"subject-19 \u2019"
        self.assertEqual(expected_subject, last_subject)