Exemplo n.º 1
0
class ApiFao:
    def __init__(self):
        '''
        Initializes the class
        '''
        self.fao1 = Fao()

    def list_presents_countries(self):
        return self.fao1.countries()

    def list_products_of_country(self, country_name):
        return self.fao1.products(country_name)

    def dict_products_of_countries(self, countries_list):
        return self.fao1.country_prod(countries_list)

    def dict_max_of_countries_productions(self, countries_list, years_filter):
        return self.fao1.max(countries_list, years_filter)

    def dict_min_of_countries_productions(self, countries_list, years_filter):
        return self.fao1.min(countries_list, years_filter)

    def dict_avg_of_countries_productions(self, countries_list, years_filter,
                                          production_filter, food_or_feed):
        return self.fao1.av(countries_list, years_filter, production_filter,
                            food_or_feed)
Exemplo n.º 2
0
class TestFao(TestCase):
    def setUp(self):
        self.data = Fao()

    def test_countries(self):
        self.assertEqual(self.data.countries()[0], "Afghanistan")

    def test_products(self):
        self.assertEqual(self.data.products("Afghanistan")[0], "Wheat and products")

    def test_min(self):
        self.assertEqual(self.data.min(["Afghanistan"], ['Y1961', 'Y2013']), "a completer")

    def test_max(self):
        self.assertEqual(self.data.max(["Afghanistan"], ['Y1961', 'Y2013']), ["Wheat and products", "Y2013"])

    def test_av(self):
        self.assertEqual(self.data.av(["Afghanistan"], ['Y1961', 'Y1965'], "Wheat and products"), 1889.8)