def setUp(self):
        # simulate getting a JSON response from a search query
        mock_json(path="seriesbr.ibge.get_json",
                  json=get_sample_json("ibge_metadata.json")).start()

        # simulate getting a JSON response from a metadata query
        mock_json(
            path="seriesbr.helpers.metadata.get_json",
            json=get_sample_json("ibge_metadata.json"),
        ).start()
Beispiel #2
0
 def test_bcb_parser(self):
     df = bcb_json_to_df(get_sample_json("bcb_json.json"), 11, "Selic")
     # assert it is a DataFrame
     self.assertIsInstance(df, pd.DataFrame)
     # index is datetime
     self.assertTrue(pd.api.types.is_datetime64_dtype(df.index))
     # series is float
     self.assertTrue(pd.api.types.is_float_dtype(df.values))
Beispiel #3
0
 def test_ipea_parser(self):
     df = ipea_json_to_df(get_sample_json("ipea_json.json"), "Código",
                          "Nome")
     # assert it is a DataFrame
     self.assertIsInstance(df, pd.DataFrame)
     # index is datetime
     self.assertTrue(pd.api.types.is_datetime64_dtype(df.index))
     # series is float
     self.assertTrue(pd.api.types.is_float_dtype(df.values))
    def test_bcb_get_search_results(self, mocked_get_json):
        mocked_get_json.return_value = get_sample_json("bcb_search_results.json")

        df = bcb_get_search_results("https://fake.com?json=call")

        test = df.columns.tolist()
        expected = ["codigo_sgs", "title", "periodicidade", "unidade_medida"]

        self.assertListEqual(test, expected)
Beispiel #5
0
 def setUp(self):
     mock_json(path="seriesbr.ibge.get_json",
               json=get_sample_json("ibge_search_results.json")).start()
Beispiel #6
0
    def test_ibge_get_metadata(self, mocked_get_json):
        mocked_get_json.return_value = get_sample_json("ibge_metadata.json")

        df = ibge.get_metadata(1419)
        self.assertFalse(df.empty)
    def test_list_cities(self, mocked_get_json):
        mocked_get_json.return_value = get_sample_json("ibge_municipios.json")

        df = ibge.list_cities()
        self.assertFalse(df.empty)
    def test_list_mesoregions(self, mocked_get_json):
        mocked_get_json.return_value = get_sample_json(
            "ibge_mesorregioes.json")

        df = ibge.list_mesoregions()
        self.assertFalse(df.empty)
 def setUp(self):
     mock_json(path="seriesbr.ibge.get_json",
               json=get_sample_json("ibge_variables.json")).start()
 def setUp(self):
     mock_json(
         path="seriesbr.helpers.metadata.get_json",
         json=get_sample_json("bcb_metadata.json"),
     ).start()
    def test_list_countries(self, mocked_get_json):
        mocked_get_json.return_value = get_sample_json("ipea_paises.json")

        test = ipea.list_countries().columns.tolist()
        expected = ["PAICODIGO", "PAINOME"]
        self.assertListEqual(test, expected)
    def test_list_themes(self, mocked_get_json):
        mocked_get_json.return_value = get_sample_json("ipea_temas.json")

        test = ipea.list_themes().columns.tolist()
        expected = ["TEMCODIGO", "TEMCODIGO_PAI", "TEMNOME"]
        self.assertListEqual(test, expected)
Beispiel #13
0
 def test_ibge_parser(self):
     df = ibge_json_to_df(get_sample_json("ibge_json.json"))
     # assert it is a DataFrame
     self.assertIsInstance(df, pd.DataFrame)
     # index is datetime
     self.assertTrue(pd.api.types.is_datetime64_dtype(df.index))
    def test_ipea_metadata_to_df(self, mocked_get_json):
        mocked_get_json.return_value = get_sample_json("ipea_metadata.json")

        df = ipea.ipea_metadata_to_df("url")
        self.assertFalse(df.empty)
Beispiel #15
0
def generate_jsons():
    """Simulate making a IPEA API response, then a BCB API response"""
    srcs = ["ipea", "bcb"]
    for src in srcs:
        yield get_sample_json(src + "_json.json")
Beispiel #16
0
 def setUp(self):
     mock_json(
         path="seriesbr.helpers.searching.get_json",
         json=get_sample_json("ipea_search_results.json"),
     ).start()