# Path: washmap/stats/models.py
# class StatDescription(Sortable):
#     class Meta(Sortable.Meta):
#         pass
# 
#     description = models.TextField()
#     code = models.SlugField()
# 
#     def __unicode__(self):
#         return self.description
# 
# class StatValue(models.Model):
#     class Meta:
#         unique_together = ('description', 'country', 'year')
# 
#     description = models.ForeignKey(StatDescription)
#     country = models.ForeignKey(Country)
#     year = models.IntegerField()
#     value = models.DecimalField(max_digits=20, decimal_places=10, null=True, blank=True)  # nopep8
# 
#     def __unicode__(self):
#         return "%s, %s, %s" % (
#             self.country,
#             self.year,
#             self.value
#         )


from decimal import Decimal
from StringIO import StringIO
from django.core.urlresolvers import reverse
from django.test import TestCase
from django_dynamic_fixture import G
from django_harness.fast_dispatch import FastDispatchMixin
from django_harness.dates import DateUtilsMixin
from django_harness.fast_dispatch import FastDispatchMixin
from django_harness.html_parsing import HtmlParsingMixin
from django_harness.override_settings import override_settings
from django_harness.plugin_testing import PluginTestMixin
from django_harness.translation import TranslationTestMixin
from django_harness.words import WordUtilsMixin
from main.models import Country
from ..models import StatDescription, StatValue
        from django.contrib.auth.models import User
        from django.contrib.auth.models import User
        from tablib.formats import _csv
        import tablib



class StatsExportTemplateTests(DateUtilsMixin, FastDispatchMixin,
    HtmlParsingMixin, PluginTestMixin, TranslationTestMixin, WordUtilsMixin,
    TestCase):

    counter = 1

    def setUp(self):
        super(StatsExportTemplateTests, self).setUp()

        self.user = G(User, is_superuser=True, is_staff=True)

        self.water = self.create(StatDescription, description="Water", code="water")

    def test_import_root_page_loads_properly_directly(self):
        response = self.fast_dispatch('admin:country-stats')
        self.assertEqual(200, response.status_code)

    def test_import_root_page_loads_properly_with_middleware(self):
        # Use self.client.get instead of fast_dispatch to ensure that
        # all middleware is hit. A problem with importing app URLs was
        # triggered by LocaleMiddleware and not reproducible with
        # fast_dispatch.
        response = self.client.get(reverse('admin:country-stats'))
        self.assertEqual(200, response.status_code)

    def assert_export_template(self, statistic=None):
        if statistic is None:

# Path: washmap/stats/models.py
# class StatDescription(Sortable):
#     class Meta(Sortable.Meta):
#         pass
# 
#     description = models.TextField()
#     code = models.SlugField()
# 
#     def __unicode__(self):
#         return self.description
# 
# class StatValue(models.Model):
#     class Meta:
#         unique_together = ('description', 'country', 'year')
# 
#     description = models.ForeignKey(StatDescription)
#     country = models.ForeignKey(Country)
#     year = models.IntegerField()
#     value = models.DecimalField(max_digits=20, decimal_places=10, null=True, blank=True)  # nopep8
# 
#     def __unicode__(self):
#         return "%s, %s, %s" % (
#             self.country,
#             self.year,
#             self.value
#         )


# Path: washmap/stats/tests/tests.py
from decimal import Decimal
from StringIO import StringIO
from django.core.urlresolvers import reverse
from django.test import TestCase
from django_dynamic_fixture import G
from django_harness.fast_dispatch import FastDispatchMixin
from django_harness.dates import DateUtilsMixin
from django_harness.fast_dispatch import FastDispatchMixin
from django_harness.html_parsing import HtmlParsingMixin
from django_harness.override_settings import override_settings
from django_harness.plugin_testing import PluginTestMixin
from django_harness.translation import TranslationTestMixin
from django_harness.words import WordUtilsMixin
from main.models import Country
from ..models import StatDescription, StatValue
        from django.contrib.auth.models import User
        from django.contrib.auth.models import User
        from tablib.formats import _csv
        import tablib




class StatsExportTemplateTests(DateUtilsMixin, FastDispatchMixin,
    HtmlParsingMixin, PluginTestMixin, TranslationTestMixin, WordUtilsMixin,
    TestCase):

    counter = 1

    def setUp(self):
        super(StatsExportTemplateTests, self).setUp()

        self.user = G(User, is_superuser=True, is_staff=True)

        self.water = self.create(StatDescription, description="Water", code="water")

    def test_import_root_page_loads_properly_directly(self):
        response = self.fast_dispatch('admin:country-stats')
        self.assertEqual(200, response.status_code)

    def test_import_root_page_loads_properly_with_middleware(self):
        # Use self.client.get instead of fast_dispatch to ensure that
        # all middleware is hit. A problem with importing app URLs was
        # triggered by LocaleMiddleware and not reproducible with
        # fast_dispatch.
        response = self.client.get(reverse('admin:country-stats'))
        self.assertEqual(200, response.status_code)

    def assert_export_template(self, statistic=None):
        if statistic is None:

            statistic = StatDescription.objects.get()