Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_decade_values(self):
data = InstrumentalDecade()
results = data.dataset.as_dict()
self.assertEqual(results["300"]["1990"], 13.437422)
def test_monthly_values(self):
data = Monthly()
self.assertEqual(data.dataset.as_dict()["IN"]["2013M04"],
54.38226363636)
def test_year_keys(self, data):
results = data.dataset.as_dict()
for region in results.values():
self.assertIn(str(2000), region)
def test_gcm_key(self, data):
self.assertIn("ingv_echam4", data.dataset.as_dict())
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)
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)
def test_month_keys(self):
data = InstrumentalMonth()
results = data.dataset.as_dict()
for region in results.values():
self.assertEqual(len(region), 12)
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())
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)
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)