# Path: tests/testapp/models.py
# class TimeSeries(models.Model):
#     date = models.DateField()
#     value = models.FloatField()
# 
#     objects = DataFrameManager()
# 
# class CustomIndexSeries(models.Model):
#     code = models.SlugField(primary_key=True)
#     value = models.FloatField()
# 
# Path: tests/settings.py
# HAS_DJANGO_PANDAS = False


import unittest
import json
import datetime
import os
from rest_framework.test import APITestCase
from tests.testapp.models import TimeSeries, CustomIndexSeries
from wq.io import load_string
from .settings import HAS_DJANGO_PANDAS
        expected = open(
            os.path.join(os.path.dirname(__file__), 'files', 'timeseries.html')
        ).read()
        self.assertHTMLEqual(expected, response.content.decode('utf-8'))

    def test_viewset(self):
        response = self.client.get("/router/timeseries.csv")
        data = self.load_string(response)
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0].value, '0.5')

    def test_mixed_renderer_csv(self):
        response = self.client.get("/mixedrenderers.csv")
        data = self.load_string(response)
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0].value, '0.5')

    def test_mixed_renderer_api(self):
        response = self.client.get("/mixedrenderers.api")
        data = self.load_string(response)
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0].value, '0.5')

    def test_mixed_renderer_json(self):
        response = self.client.get("/mixedrenderers.json")
        data = json.loads(response.content.decode('utf-8'))
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0]['value'], 0.5)

    def test_custom_csv_date_format(self):

# Path: tests/testapp/models.py
# class TimeSeries(models.Model):
#     date = models.DateField()
#     value = models.FloatField()
# 
#     objects = DataFrameManager()
# 
# class CustomIndexSeries(models.Model):
#     code = models.SlugField(primary_key=True)
#     value = models.FloatField()
# 
# Path: tests/settings.py
# HAS_DJANGO_PANDAS = False


# Path: tests/test_views.py
import unittest
import json
import datetime
import os
from rest_framework.test import APITestCase
from tests.testapp.models import TimeSeries, CustomIndexSeries
from wq.io import load_string
from .settings import HAS_DJANGO_PANDAS

        expected = open(
            os.path.join(os.path.dirname(__file__), 'files', 'timeseries.html')
        ).read()
        self.assertHTMLEqual(expected, response.content.decode('utf-8'))

    def test_viewset(self):
        response = self.client.get("/router/timeseries.csv")
        data = self.load_string(response)
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0].value, '0.5')

    def test_mixed_renderer_csv(self):
        response = self.client.get("/mixedrenderers.csv")
        data = self.load_string(response)
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0].value, '0.5')

    def test_mixed_renderer_api(self):
        response = self.client.get("/mixedrenderers.api")
        data = self.load_string(response)
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0].value, '0.5')

    def test_mixed_renderer_json(self):
        response = self.client.get("/mixedrenderers.json")
        data = json.loads(response.content.decode('utf-8'))
        self.assertEqual(len(data), 5)
        self.assertEqual(data[0]['value'], 0.5)

    def test_custom_csv_date_format(self):

        response = self.client.get("/customcsv.csv")