# Path: washmap/stats/models.py
# 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
#         )


import pytest
from bs4 import BeautifulSoup
from django_dynamic_fixture import G
from main.models import Country
from ..models import StatValue
    assert "2014" in stats_cells[0].find(class_="_stat_year").text
    # For Angola
    assert "3" in stats_cells[1].find(class_="_stat_value").text
    assert "2011" in stats_cells[1].find(class_="_stat_year").text


@pytest.mark.django_db
@pytest.mark.urls('country_comparison.test_urls')
def test_not_visible_gives_a_blank_stat_value_and_no_stat_year(
    tt, stat_a_i, zambia, comparison_url, client
):
    angola = tt.create(Country, slug='angola', local_name="Angola")

    # Create stats for angola and zambia to display
    G(StatValue, description=stat_a_i, country=zambia, year=201, visible=False)
    G(StatValue, description=stat_a_i, country=zambia, year=200, visible=False)
    G(StatValue, description=stat_a_i, country=angola, year=2010, value=4)

    # Get the Zambia Page
    response = client.get("%s?country=%s" % (comparison_url, angola.slug))
    assert response.status_code == 200
    soup = BeautifulSoup(response.content.decode('utf-8'))

    # Expect a row with the correct description
    stats_row = soup.find_all(class_="_stat")
    assert len(stats_row) == 1

    # Expect the first column to have the zambian latest, and the second, the
    # angolan latest
    stats_cells = stats_row[0].find_all(class_="_stat_cell")

# Path: washmap/stats/models.py
# 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/country_comparison_view_tests.py
import pytest
from bs4 import BeautifulSoup
from django_dynamic_fixture import G
from main.models import Country
from ..models import StatValue

    assert "2014" in stats_cells[0].find(class_="_stat_year").text
    # For Angola
    assert "3" in stats_cells[1].find(class_="_stat_value").text
    assert "2011" in stats_cells[1].find(class_="_stat_year").text


@pytest.mark.django_db
@pytest.mark.urls('country_comparison.test_urls')
def test_not_visible_gives_a_blank_stat_value_and_no_stat_year(
    tt, stat_a_i, zambia, comparison_url, client
):
    angola = tt.create(Country, slug='angola', local_name="Angola")

    # Create stats for angola and zambia to display
    G(StatValue, description=stat_a_i, country=zambia, year=201, visible=False)
    G(StatValue, description=stat_a_i, country=zambia, year=200, visible=False)
    G(StatValue, description=stat_a_i, country=angola, year=2010, value=4)

    # Get the Zambia Page
    response = client.get("%s?country=%s" % (comparison_url, angola.slug))
    assert response.status_code == 200
    soup = BeautifulSoup(response.content.decode('utf-8'))

    # Expect a row with the correct description
    stats_row = soup.find_all(class_="_stat")
    assert len(stats_row) == 1

    # Expect the first column to have the zambian latest, and the second, the
    # angolan latest
    stats_cells = stats_row[0].find_all(class_="_stat_cell")

    assert len(stats_cells) == 2