From a97e54557d394c41231841c6d21ab94f7992baf2 Mon Sep 17 00:00:00 2001 From: philsv Date: Tue, 24 Jan 2023 03:31:14 +0100 Subject: [PATCH] refactor: bump up version / fix import modules / add test --- pyproject.toml | 4 ++++ setup.py | 3 ++- src/myeia.py | 18 ++---------------- src/version.py | 2 +- tests/test_myeia.py | 9 +++++++++ 5 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 pyproject.toml create mode 100644 tests/test_myeia.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b4a69d6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.pytest.ini_options] +pythonpath = [ + ".", "src", "tests", "src", +] \ No newline at end of file diff --git a/setup.py b/setup.py index 459c36b..4a16311 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,12 @@ import setuptools +from src.version import __version__ with open("README.md", "r") as ld: long_description = ld.read() setuptools.setup( name="myeia", - version="0.2.0", + version=__version__, url="https://github.com/philsv/myeia", license="MIT", author="philsv", diff --git a/src/myeia.py b/src/myeia.py index 0c705f5..67672e0 100644 --- a/src/myeia.py +++ b/src/myeia.py @@ -6,9 +6,8 @@ import pandas as pd import requests from dotenv import load_dotenv -from pandas.core.common import SettingWithCopyWarning -warnings.simplefilter(action="ignore", category=SettingWithCopyWarning) +warnings.simplefilter(action="ignore", category=pd.errors.PerformanceWarning) load_dotenv() @@ -37,9 +36,7 @@ def get_data( "Accept": "*/*", } - api_route = ( - f"{route}/data/?api_key={self.token}&data[]=value&frequency={frequency}" - ) + api_route = f"{route}/data/?api_key={self.token}&data[]=value&frequency={frequency}" series = f"&facets[{facet}][]={series}" @@ -73,15 +70,4 @@ def get_data( df.rename(columns={df.columns[0]: "Date"}, inplace=True) df["Date"] = pd.to_datetime(df["Date"]) df.set_index("Date", inplace=True) - return df - - -# if __name__ == "__main__": - -# # Example -# eia = API() -# df = eia.get_data( -# route="steo", series="PAPR_OPEC", frequency="monthly", facet="seriesId" -# ) -# print(df.head()) diff --git a/src/version.py b/src/version.py index d3ec452..3ced358 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -__version__ = "0.2.0" +__version__ = "0.2.1" diff --git a/tests/test_myeia.py b/tests/test_myeia.py new file mode 100644 index 0000000..79e4617 --- /dev/null +++ b/tests/test_myeia.py @@ -0,0 +1,9 @@ +import pandas as pd + +from src import myeia + + +def test_get_data(): + eia = myeia.API() + df = eia.get_data(route="natural-gas/pri/fut", series="RNGC1", frequency="daily") + assert isinstance(df, pd.DataFrame) \ No newline at end of file