From 26909d9d6c980c2e046d28a423660584590e1ec0 Mon Sep 17 00:00:00 2001 From: Cedric Boudinet Date: Mon, 18 Sep 2023 14:38:16 +0200 Subject: [PATCH 1/2] code reorganisation for better api installation and unit test --- api_rte/__init__.py | 1 + api_rte.py => api_rte/api.py | 2 +- api_config.py => api_rte/config.py | 2 +- setup.py | 10 ++++++---- tests/__init__.py | 1 + tests/test_api.py | 4 ++-- tests/test_config.py | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 api_rte/__init__.py rename api_rte.py => api_rte/api.py (99%) rename api_config.py => api_rte/config.py (97%) create mode 100644 tests/__init__.py diff --git a/api_rte/__init__.py b/api_rte/__init__.py new file mode 100644 index 0000000..1a72d32 --- /dev/null +++ b/api_rte/__init__.py @@ -0,0 +1 @@ +__version__ = '1.1.0' diff --git a/api_rte.py b/api_rte/api.py similarity index 99% rename from api_rte.py rename to api_rte/api.py index 302798d..2a45a28 100644 --- a/api_rte.py +++ b/api_rte/api.py @@ -2,7 +2,7 @@ import requests import pandas as pd -from api_config import * +from api_rte.config import * def get_token(oauth_url=OAUTH_URL, diff --git a/api_config.py b/api_rte/config.py similarity index 97% rename from api_config.py rename to api_rte/config.py index e627523..e5c9df7 100644 --- a/api_config.py +++ b/api_rte/config.py @@ -27,4 +27,4 @@ 'D-2', # 2 days ahead 'D-1', # 1 days ahead 'CURRENT', # current - 'ID'] # intra-day \ No newline at end of file + 'ID'] # intra-day diff --git a/setup.py b/setup.py index 7ee8d0b..ddcd6c7 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,14 @@ from setuptools import setup - +import api_rte setup( name='api_rte', - version=1.1, + version=api_rte.__version__, description='Library RTE API', author='Vincent Reinbold', author_email='vincent.reinbold@geeps.centralesupelec.fr', license='GNU GENERAL PUBLIC LICENSE v3', - packages=[], - classifiers=["Programming Language :: Python :: 3.7"], install_requires=['requests', 'urllib3', 'pandas'] + packages=['api_rte'], + classifiers=["Programming Language :: Python :: 3.7"], + install_requires=['requests', 'urllib3', 'pandas'], + test_suite='tests', ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..2071d06 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +from unittest import TestCase diff --git a/tests/test_api.py b/tests/test_api.py index dfa7fc6..46174da 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,6 +1,6 @@ import unittest -from api_config import * -from api_rte import * +from api_rte.config import * +from api_rte.api import * import datetime diff --git a/tests/test_config.py b/tests/test_config.py index 58fe00b..e8efcba 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,5 +1,5 @@ import unittest -from api_config import * +from api_rte.config import * class TestConfig(unittest.TestCase): From 9cd63db141bd1069396ec95bc44424308cd4a8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Boudinet?= Date: Mon, 18 Sep 2023 14:49:52 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 97421c9..0c96deb 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ Code source for downloading rte data using rte digital on-line services : https: pip install git+https://github.com/ReinboldV/api_rte.git -1) Create a profile at https://data.rte-france.com/. +2) Create a profile at https://data.rte-france.com/. -2) Create an application for web server and start associating API to this application. Note that you won't have access to API if note associated with you application. +3) Create an application for web server and start associating API to this application. Note that you won't have access to API if note associated with you application. - In the application tab, one will find the `client id` and the related `client secret` code needed for requesting data. Add those to the configuration file `api_config.py`. + In the application tab, one will find the `client id` and the related `client secret` code needed for requesting data. Add those to the configuration file `api_rte\config.py`. CLIENT_ID = '7699170f-9898-40d0-b78a-XXXXXXXXXXXX' CLIENT_SECRET = '969de489-1dca-4158-8ad4-XXXXXXXXXXXX' -3) Testing the configuration and the api : +4) Testing the configuration and the api : python tests/test_conf.py python tests/test_api.py @@ -32,7 +32,7 @@ Code source for downloading rte data using rte digital on-line services : https: Here is a minimal example for tempo tarifs : - from api_rte import * + from api_rte.api import * import datetime start_date = datetime.datetime.today() - datetime.timedelta(days=2) # before yesterday @@ -42,7 +42,7 @@ Code source for downloading rte data using rte digital on-line services : https: Here is a minimal example for one day ahead wind production forecasts : - from api_rte import * + from api_rte.api import * import datetime start_date = datetime.datetime.today() - datetime.timedelta(days=2) # before yesterday