def test_url_start_and_classifications(self): test = ibge.get_series(1419, start="07-2017", classifications={315: [7169, 7170]}) expected = ( BASEURL + "/201707-201912/variaveis?classificacao=315[7169,7170]&localidades=BR&view=flat" # noqa: W503 ) self.assertEqual(test, expected)
def test_url_start_classifications_and_regions(self): expected = ( BASEURL + "/201707-201912/variaveis/63?classificacao=315[7169,7170]&localidades=N7|BR&view=flat" # noqa: W503 ) test = ibge.get_series( 1419, variables=63, start="07-2017", mesoregions="all", brazil="yes", classifications={315: [7169, 7170]}, ) self.assertEqual(test, expected)
def test_url_start_and_end_date_complete_dates(self): test = ibge.get_series(1419, start="05072017", end="12092018") expected = BASEURL + "/201707-201809/variaveis?&localidades=BR&view=flat" self.assertEqual(test, expected)
def test_url_end_date_complete_dates(self): test = ibge.get_series(1419, end="06/09/2018") expected = BASEURL + "/190001-201809/variaveis?&localidades=BR&view=flat" self.assertEqual(test, expected)
def test_url_start_date_complete_dates(self): test = ibge.get_series(1419, start="03-09-2018") expected = BASEURL + "/201809-201912/variaveis?&localidades=BR&view=flat" self.assertEqual(test, expected)
def test_url_start_and_end_date_year_only(self): test = ibge.get_series(1419, start="2017", end="2018") expected = BASEURL + "/201701-201812/variaveis?&localidades=BR&view=flat" self.assertEqual(test, expected)
def test_url_with_start_date_year_only(self): test = ibge.get_series(1419, start="2019") expected = BASEURL + "/201901-201912/variaveis?&localidades=BR&view=flat" self.assertEqual(test, expected)
def test_url_no_dates(self): test = ibge.get_series(1419) expected = BASEURL + "/190001-201912/variaveis?&localidades=BR&view=flat" self.assertEqual(test, expected)
def test_crazy_date(self): with self.assertRaises(ValueError): ibge.get_series(1419, start="asfhajksfsa")