Exemplo n.º 1
0
    def test_export(self):
        from_date = now() - timedelta(weeks=2)
        to_date = now() + timedelta(weeks=1)
        data = {'from_date': from_date, 'to_date': to_date, '_save': 'Confirm'}
        tenant = connection.tenant
        initiatives = InitiativeFactory.create_batch(4)
        for initiative in initiatives:
            EventFactory.create_batch(3, initiative=initiative)
            AssignmentFactory.create_batch(2, initiative=initiative)
            FundingFactory.create_batch(1, initiative=initiative)

        result = plain_export(Exporter, tenant=tenant, **data)
        book = xlrd.open_workbook(result)
        self.assertEqual(book.sheet_by_name('Users').ncols, 11)
        self.assertEqual(book.sheet_by_name('Users').nrows, 41)
        self.assertEqual(book.sheet_by_name('Initiatives').nrows, 5)
        self.assertEqual(book.sheet_by_name('Funding activities').nrows, 5)
        self.assertEqual(book.sheet_by_name('Events').nrows, 13)
        self.assertEqual(
            book.sheet_by_name('Events').cell(0, 13).value, 'Start')
        self.assertEqual(
            book.sheet_by_name('Events').cell(0, 14).value, 'Time needed')

        self.assertEqual(book.sheet_by_name('Tasks').nrows, 9)
        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 16).value, 'Preparation time')
        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 17).value, 'Start time')
        self.assertEqual(
            book.sheet_by_name('Tasks').cell(0, 19).value, 'End date')
Exemplo n.º 2
0
 def test_activities_from_homepage(self):
     EventFactory.create_batch(10, status='open', highlight=True)
     ActivitiesContent.objects.create_for_placeholder(self.placeholder,
                                                      highlighted=True)
     response = self.client.get(self.url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data['blocks'][0]['type'], 'activities')
     self.assertEqual(len(response.data['blocks'][0]['activities']), 4)
Exemplo n.º 3
0
    def test_limits(self):
        initiative = InitiativeFactory.create()
        EventFactory.create_batch(
            7,
            status='open',
            initiative=initiative,
        )
        response = self.client.get(self.url + '?page[size]=150',
                                   user=self.owner)
        self.assertEqual(len(response.json()['data']), 7)

        response = self.client.get(self.url + '?page[size]=3', user=self.owner)
        self.assertEqual(len(response.json()['data']), 3)