Esempio n. 1
0
 def test_csv_name(self):
     generator = ResponseFormatterGenerator('csv').get_formatter()
     response = generator.run(self.query, {})
     self.assertEquals(
         response.get('Content-Disposition'),
         'attachment; filename="{}"'.format(
             constants.CSV_RESPONSE_FILENAME))
    def test_csv_different_decimal_empty_rows(self):
        query = Query()

        field = Field.objects.get(identifier=self.single_series)
        query.add_series(field)
        query.add_series(field, rep_mode='percent_change_a_year_ago')

        generator = ResponseFormatterGenerator('csv').get_formatter()
        response = generator.run(query, {'decimal': ','})

        self.assertFalse("None" in str(response.content))
Esempio n. 3
0
 def test_csv_response_header_description(self):
     generator = ResponseFormatterGenerator('csv').get_formatter()
     response = generator.run(self.query, {'header': 'descriptions'})
     line_end = str(response.content).find('\n')
     header = response.content[:line_end]
     self.assertIn(self.series_desc, str(header))
Esempio n. 4
0
 def test_csv_response_header(self):
     generator = ResponseFormatterGenerator('csv').get_formatter()
     response = generator.run(self.query, {'header': 'titles'})
     line_end = str(response.content).find('\n')
     header = response.content[:line_end]
     self.assertTrue(self.series_name in str(header))
Esempio n. 5
0
    def test_json_response(self):
        generator = ResponseFormatterGenerator('json').get_formatter()
        response = generator.run(self.query, {})

        self.assertEqual(response.get('Content-Type'), 'application/json')
Esempio n. 6
0
    def test_csv_response(self):
        generator = ResponseFormatterGenerator('csv').get_formatter()
        response = generator.run(self.query, {})

        self.assertTrue(response.get('Content-Type'), 'text/csv')
Esempio n. 7
0
 def setupHeader(self, query, header):
     generator = ResponseFormatterGenerator('csv').get_formatter()
     response = generator.run(query, {'header': header})
     line_end = str(response.content).find('\n')
     return response.content[:line_end]