How to use the ddt.data.dataset.as_dict function in ddt

To help you get started, we’ve selected a few ddt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattduck / wbpy / tests / climate.py View on Github external
def test_decade_values(self):
        data = InstrumentalDecade()
        results = data.dataset.as_dict()
        self.assertEqual(results["300"]["1990"], 13.437422)
github mattduck / wbpy / tests / indicators.py View on Github external
def test_monthly_values(self):
            data = Monthly()
            self.assertEqual(data.dataset.as_dict()["IN"]["2013M04"], 
                54.38226363636)
github mattduck / wbpy / tests / climate.py View on Github external
def test_year_keys(self, data):
        results = data.dataset.as_dict()
        for region in results.values():
            self.assertIn(str(2000), region)
github mattduck / wbpy / tests / climate.py View on Github external
def test_gcm_key(self, data):
        self.assertIn("ingv_echam4", data.dataset.as_dict())
github mattduck / wbpy / tests / climate.py View on Github external
def test_region_keys(self, data):
        dataset_regions = [x["region"][0] for x in data.dataset.api_calls]
        for key in data.dataset.as_dict():
            self.assertIn(key, dataset_regions)
github mattduck / wbpy / tests / indicators.py View on Github external
def test_country_keys(self, data):
            resp = data.response[1]
            expected = sorted(list(set([row["country"]["id"] for row in resp])))
            self.assertEqual(sorted(data.dataset.as_dict().keys()), 
                expected)
github mattduck / wbpy / tests / climate.py View on Github external
def test_month_keys(self):
        data = InstrumentalMonth()
        results = data.dataset.as_dict()
        for region in results.values():
            self.assertEqual(len(region), 12)
github mattduck / wbpy / tests / indicators.py View on Github external
def test_quarterly_datetime_param(self):
            data = Quarterly()
            results = data.dataset.as_dict(use_datetime=True).values()
            first_country = results[0]
            self.assertIn(datetime.date(2013, 4, 1), first_country.keys())
github mattduck / wbpy / tests / indicators.py View on Github external
def test_yearly_values(self):
            data = Yearly()
            self.assertEqual(data.dataset.as_dict()["AR"]["2011"], 40728738)
            self.assertEqual(data.dataset.as_dict()["GB"]["2012"], 63227526)
            self.assertEqual(data.dataset.as_dict()["HK"]["2012"], 7154600)
github mattduck / wbpy / tests / climate.py View on Github external
def test_date_key_monthly(self, foo):
        data, year = foo
        res = data.dataset.as_dict()
        for gcm_dict in res.values():
            for region_dict in gcm_dict.values():
                self.assertEqual(len(region_dict[year]), 12)