def get(self, path, *args, **kwargs): if not path.startswith("/"): path = "/" + path response = self.server.get(path, *args, **kwargs) try: result = json.loads(compat.to_str(response.data)) except ValueError: result = response.data return (result, response.status_code)
def test_aggregate_csv_headers(self): # Default = labels url = "cube/aggregate_test/aggregate?drilldown=date&format=csv" response, status = self.get(url) response = compat.to_str(response) reader = csv.reader(response.splitlines()) header = next(reader) self.assertSequenceEqual(["Year", "Total Amount", "Item Count"], header) # Labels - explicit url = "cube/aggregate_test/aggregate?drilldown=date&format=csv&header=labels" response, status = self.get(url) response = compat.to_str(response) reader = csv.reader(response.splitlines()) header = next(reader) self.assertSequenceEqual(["Year", "Total Amount", "Item Count"], header) # Names url = "cube/aggregate_test/aggregate?drilldown=date&format=csv&header=names" response, status = self.get(url) response = compat.to_str(response) reader = csv.reader(response.splitlines()) header = next(reader) self.assertSequenceEqual(["date.year", "amount_sum", "count"], header) # None url = "cube/aggregate_test/aggregate?drilldown=date&format=csv&header=none" response, status = self.get(url) response = compat.to_str(response) reader = csv.reader(response.splitlines()) header = next(reader) self.assertSequenceEqual(["2013", "100", "5"], header)