# 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 "2010" in stats_cells[0].find(class_="_stat_year").text


@pytest.mark.django_db
@pytest.mark.urls('country_comparison.test_urls')
def test_data_is_humanized_for_long_number(
    tt, stat_a_i, zambia, comparison_url, client
):
    # Create stats for angola forcing zambia to show no data
    G(StatValue, description=stat_a_i, country=zambia, year=10, value=1000000)

    # Get the Zambia Page
    response = client.get(comparison_url)
    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

    stats_cells = stats_row[0].find_all(class_="_stat_cell")
    assert "1M" in stats_cells[0].find(class_="_stat_value").text


@pytest.mark.django_db
@pytest.mark.urls('country_comparison.test_urls')
def test_data_is_humanized_for_small_number(
    tt, stat_a_i, zambia, comparison_url, client
):
    # Create stats for angola forcing zambia to show no data

# 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 "2010" in stats_cells[0].find(class_="_stat_year").text


@pytest.mark.django_db
@pytest.mark.urls('country_comparison.test_urls')
def test_data_is_humanized_for_long_number(
    tt, stat_a_i, zambia, comparison_url, client
):
    # Create stats for angola forcing zambia to show no data
    G(StatValue, description=stat_a_i, country=zambia, year=10, value=1000000)

    # Get the Zambia Page
    response = client.get(comparison_url)
    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

    stats_cells = stats_row[0].find_all(class_="_stat_cell")
    assert "1M" in stats_cells[0].find(class_="_stat_value").text


@pytest.mark.django_db
@pytest.mark.urls('country_comparison.test_urls')
def test_data_is_humanized_for_small_number(
    tt, stat_a_i, zambia, comparison_url, client
):
    # Create stats for angola forcing zambia to show no data

    G(StatValue, description=stat_a_i, country=zambia, year=10, value=1.23482)