# 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
from __future__ import unicode_literals, absolute_import








class StatVisibilityTests(TranslationTestMixin, TestCase):
    counter = 1

    def setUp(self):
        self.zambia = self.create(Country, name='Zambia')
        self.egypt = self.create(Country, name='Egypt')

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

        self.zambia_water = G(StatValue, country=self.zambia, description=water)
        self.zambia_sanitation = G(StatValue, country=self.zambia, description=sanitation)
        self.egypt_water = G(StatValue, country=self.egypt, description=water)
        self.egypt_sanitation = G(StatValue, country=self.egypt, description=sanitation)

    def test_visible_stat_manager(self):
        StatValue.objects.filter(country=self.zambia).update(visible=False)
        self.assertEqual(2, StatValue.objects.filter(visible=False).count())


# 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

from __future__ import unicode_literals, absolute_import








class StatVisibilityTests(TranslationTestMixin, TestCase):
    counter = 1

    def setUp(self):
        self.zambia = self.create(Country, name='Zambia')
        self.egypt = self.create(Country, name='Egypt')

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

        self.zambia_water = G(StatValue, country=self.zambia, description=water)
        self.zambia_sanitation = G(StatValue, country=self.zambia, description=sanitation)
        self.egypt_water = G(StatValue, country=self.egypt, description=water)
        self.egypt_sanitation = G(StatValue, country=self.egypt, description=sanitation)

    def test_visible_stat_manager(self):
        StatValue.objects.filter(country=self.zambia).update(visible=False)
        self.assertEqual(2, StatValue.objects.filter(visible=False).count())


        values = StatValue.visible_objects.all()