pygazpar 1.2.7__py312-none-any.whl → 1.3.0a11__py312-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- pygazpar/datasource.py +35 -19
- pygazpar/excelparser.py +1 -1
- pygazpar/jsonparser.py +1 -1
- pygazpar/version.py +1 -1
- {pygazpar-1.2.7.dist-info → pygazpar-1.3.0a11.dist-info}/METADATA +4 -22
- {pygazpar-1.2.7.dist-info → pygazpar-1.3.0a11.dist-info}/RECORD +12 -12
- {pygazpar-1.2.7.dist-info → pygazpar-1.3.0a11.dist-info}/WHEEL +1 -1
- tests/test_client.py +145 -159
- tests/test_datasource.py +166 -166
- {pygazpar-1.2.7.dist-info → pygazpar-1.3.0a11.dist-info}/LICENSE.md +0 -0
- {pygazpar-1.2.7.dist-info → pygazpar-1.3.0a11.dist-info}/entry_points.txt +0 -0
- {pygazpar-1.2.7.dist-info → pygazpar-1.3.0a11.dist-info}/top_level.txt +0 -0
pygazpar/datasource.py
CHANGED
@@ -59,9 +59,9 @@ class WebDataSource(IDataSource):
|
|
59
59
|
# ------------------------------------------------------
|
60
60
|
def load(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
|
61
61
|
|
62
|
-
self._login(self.__username, self.__password)
|
62
|
+
auth_token = self._login(self.__username, self.__password)
|
63
63
|
|
64
|
-
res = self._loadFromSession(pceIdentifier, startDate, endDate, frequencies)
|
64
|
+
res = self._loadFromSession(auth_token, pceIdentifier, startDate, endDate, frequencies)
|
65
65
|
|
66
66
|
Logger.debug("The data update terminates normally")
|
67
67
|
|
@@ -88,23 +88,23 @@ class WebDataSource(IDataSource):
|
|
88
88
|
|
89
89
|
jar = http.cookiejar.CookieJar()
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
session = Session()
|
92
|
+
session.headers.update({"Content-Type": "application/json"})
|
93
|
+
session.headers.update({"X-Requested-With": "XMLHttpRequest"})
|
94
94
|
|
95
95
|
params = json.loads(AUTH_TOKEN_PARAMS.format(session_token))
|
96
96
|
|
97
|
-
response =
|
97
|
+
response = session.get(AUTH_TOKEN_URL, params=params, allow_redirects=True, cookies=jar)
|
98
98
|
|
99
99
|
if response.status_code != 200:
|
100
100
|
raise Exception(f"An error occurred while getting the auth token. Status code: {response.status_code} - {response.text}")
|
101
101
|
|
102
|
-
auth_token =
|
102
|
+
auth_token = session.cookies.get("auth_token", domain="monespace.grdf.fr")
|
103
103
|
|
104
|
-
return auth_token
|
104
|
+
return auth_token
|
105
105
|
|
106
106
|
@abstractmethod
|
107
|
-
def _loadFromSession(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
|
107
|
+
def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
|
108
108
|
pass
|
109
109
|
|
110
110
|
|
@@ -133,7 +133,7 @@ class ExcelWebDataSource(WebDataSource):
|
|
133
133
|
self.__tmpDirectory = tmpDirectory
|
134
134
|
|
135
135
|
# ------------------------------------------------------
|
136
|
-
def _loadFromSession(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
|
136
|
+
def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
|
137
137
|
|
138
138
|
res = {}
|
139
139
|
|
@@ -166,8 +166,16 @@ class ExcelWebDataSource(WebDataSource):
|
|
166
166
|
retry = 10
|
167
167
|
while retry > 0:
|
168
168
|
|
169
|
+
# Create a session.
|
170
|
+
session = Session()
|
171
|
+
session.headers.update({"Host": "monespace.grdf.fr"})
|
172
|
+
session.headers.update({"Domain": "grdf.fr"})
|
173
|
+
session.headers.update({"X-Requested-With": "XMLHttpRequest"})
|
174
|
+
session.headers.update({"Accept": "application/json"})
|
175
|
+
session.cookies.set("auth_token", auth_token, domain="monespace.grdf.fr")
|
176
|
+
|
169
177
|
try:
|
170
|
-
self.__downloadFile(
|
178
|
+
self.__downloadFile(session, downloadUrl, self.__tmpDirectory)
|
171
179
|
break
|
172
180
|
except Exception as e:
|
173
181
|
|
@@ -203,7 +211,7 @@ class ExcelWebDataSource(WebDataSource):
|
|
203
211
|
|
204
212
|
response = session.get(url)
|
205
213
|
|
206
|
-
if "text/html" in response.headers.get("Content-Type"):
|
214
|
+
if "text/html" in response.headers.get("Content-Type"):
|
207
215
|
raise Exception("An error occurred while loading data. Please check your credentials.")
|
208
216
|
|
209
217
|
if response.status_code != 200:
|
@@ -259,7 +267,7 @@ class JsonWebDataSource(WebDataSource):
|
|
259
267
|
|
260
268
|
super().__init__(username, password)
|
261
269
|
|
262
|
-
def _loadFromSession(self, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
|
270
|
+
def _loadFromSession(self, auth_token: str, pceIdentifier: str, startDate: date, endDate: date, frequencies: Optional[List[Frequency]] = None) -> MeterReadingsByFrequency:
|
263
271
|
|
264
272
|
res = {}
|
265
273
|
|
@@ -278,10 +286,18 @@ class JsonWebDataSource(WebDataSource):
|
|
278
286
|
retry = 10
|
279
287
|
while retry > 0:
|
280
288
|
|
289
|
+
# Create a session.
|
290
|
+
session = Session()
|
291
|
+
session.headers.update({"Host": "monespace.grdf.fr"})
|
292
|
+
session.headers.update({"Domain": "grdf.fr"})
|
293
|
+
session.headers.update({"X-Requested-With": "XMLHttpRequest"})
|
294
|
+
session.headers.update({"Accept": "application/json"})
|
295
|
+
session.cookies.set("auth_token", auth_token, domain="monespace.grdf.fr")
|
296
|
+
|
281
297
|
try:
|
282
|
-
response =
|
298
|
+
response = session.get(downloadUrl)
|
283
299
|
|
284
|
-
if "text/html" in response.headers.get("Content-Type"):
|
300
|
+
if "text/html" in response.headers.get("Content-Type"):
|
285
301
|
raise Exception("An error occurred while loading data. Please check your credentials.")
|
286
302
|
|
287
303
|
if response.status_code != 200:
|
@@ -305,7 +321,7 @@ class JsonWebDataSource(WebDataSource):
|
|
305
321
|
temperaturesUrl = JsonWebDataSource.TEMPERATURES_URL.format(pceIdentifier, endDate.strftime(JsonWebDataSource.INPUT_DATE_FORMAT), days)
|
306
322
|
|
307
323
|
# Get weather data.
|
308
|
-
temperatures =
|
324
|
+
temperatures = session.get(temperaturesUrl).text
|
309
325
|
|
310
326
|
# Transform all the data into the target structure.
|
311
327
|
daily = JsonParser.parse(data, temperatures, pceIdentifier)
|
@@ -450,7 +466,7 @@ class FrequencyConverter:
|
|
450
466
|
df = df.sort_values(by=['first_day_of_week'])
|
451
467
|
|
452
468
|
# Select rows where we have a full week (7 days) except for the current week.
|
453
|
-
df = pd.concat([df[(df["count"] >= 7)], df.tail(1)[df
|
469
|
+
df = pd.concat([df[(df["count"] >= 7)], df.tail(1)[df["count"] < 7]])
|
454
470
|
|
455
471
|
# Select target columns.
|
456
472
|
df = df[["time_period", "start_index_m3", "end_index_m3", "volume_m3", "energy_kwh", "timestamp"]]
|
@@ -478,7 +494,7 @@ class FrequencyConverter:
|
|
478
494
|
df = df.sort_values(by=['first_day_of_month'])
|
479
495
|
|
480
496
|
# Select rows where we have a full month (more than 27 days) except for the current month.
|
481
|
-
df = pd.concat([df[(df["count"] >= 28)], df.tail(1)[df
|
497
|
+
df = pd.concat([df[(df["count"] >= 28)], df.tail(1)[df["count"] < 28]])
|
482
498
|
|
483
499
|
# Rename columns for their target names.
|
484
500
|
df = df.rename(columns={"month_year": "time_period"})
|
@@ -509,7 +525,7 @@ class FrequencyConverter:
|
|
509
525
|
df = df.sort_values(by=['year'])
|
510
526
|
|
511
527
|
# Select rows where we have almost a full year (more than 360) except for the current year.
|
512
|
-
df = pd.concat([df[(df["count"] >= 360)], df.tail(1)[df
|
528
|
+
df = pd.concat([df[(df["count"] >= 360)], df.tail(1)[df["count"] < 360]])
|
513
529
|
|
514
530
|
# Rename columns for their target names.
|
515
531
|
df = df.rename(columns={"year": "time_period"})
|
pygazpar/excelparser.py
CHANGED
pygazpar/jsonparser.py
CHANGED
@@ -29,7 +29,7 @@ class JsonParser:
|
|
29
29
|
|
30
30
|
for releve in data[pceIdentifier]['releves']:
|
31
31
|
temperature = releve['temperature']
|
32
|
-
if temperature is None
|
32
|
+
if temperature is None:
|
33
33
|
temperature = temperatures.get(releve['journeeGaziere'])
|
34
34
|
|
35
35
|
item = {}
|
pygazpar/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "1.
|
1
|
+
__version__ = "1.3.0a11"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pygazpar
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.3.0a11
|
4
4
|
Summary: Retrieve gas consumption from GrDF web site (French Gas Company)
|
5
5
|
Home-page: https://github.com/ssenart/pygazpar
|
6
6
|
Download-URL: https://github.com/ssenart/pygazpar/releases
|
@@ -32,7 +32,9 @@ Requires-Dist: pandas
|
|
32
32
|
|
33
33
|
# PyGazpar
|
34
34
|
|
35
|
-
##
|
35
|
+
## <span style="color:green">!!! This library is working again. CAPTCHA has been removed !!!</span>
|
36
|
+
|
37
|
+
## <span style="color:red">~~!!! This library is broken since CAPTCHA is mandatory on GrDF site !!!~~</span>
|
36
38
|
|
37
39
|
PyGazpar is a Python library for getting natural gas consumption from GrDF French provider.
|
38
40
|
|
@@ -218,26 +220,6 @@ All notable changes to this project will be documented in this file.
|
|
218
220
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
219
221
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
220
222
|
|
221
|
-
## [1.2.7](https://github.com/ssenart/PyGazpar/compare/1.2.7...1.2.6) - 2025-01-06
|
222
|
-
|
223
|
-
### Fixed
|
224
|
-
- [#79](https://github.com/ssenart/PyGazpar/issues/79): Fix some unittests that wrongly failed because of the new year.
|
225
|
-
|
226
|
-
## [1.2.6](https://github.com/ssenart/PyGazpar/compare/1.2.6...1.2.5) - 2025-01-03
|
227
|
-
|
228
|
-
### Fixed
|
229
|
-
- [#77](https://github.com/ssenart/PyGazpar/issues/77): Some error may occur while requesting data from GrDF API.
|
230
|
-
|
231
|
-
## [1.2.5](https://github.com/ssenart/PyGazpar/compare/1.2.5...1.2.4) - 2024-12-21
|
232
|
-
|
233
|
-
### Fixed
|
234
|
-
- [#75](https://github.com/ssenart/PyGazpar/issues/75): Fix an error when no temperature data is available.
|
235
|
-
|
236
|
-
## [1.2.4](https://github.com/ssenart/PyGazpar/compare/1.2.4...1.2.3) - 2024-10-09
|
237
|
-
|
238
|
-
### Fixed
|
239
|
-
- [#72](https://github.com/ssenart/PyGazpar/issues/72): Remove the warning message "UserWarning: Boolean Series key will be reindexed to match DataFrame index. df = pd.concat([df[(df["count"] >= 7)], df.tail(1)[df["count"] < 7]])".
|
240
|
-
|
241
223
|
## [1.2.3](https://github.com/ssenart/PyGazpar/compare/1.2.3...1.2.1) - 2024-10-05
|
242
224
|
|
243
225
|
### Added
|
@@ -1,11 +1,11 @@
|
|
1
1
|
pygazpar/__init__.py,sha256=qshO_XZbDA2Wrt80ABDs0MoScqJytClAuIJjAnILglk,309
|
2
2
|
pygazpar/__main__.py,sha256=Pt3PInX7QiWcs0aBKZN90NTaU8KFnrQiZ5Hsow1eR5U,3177
|
3
3
|
pygazpar/client.py,sha256=JdVm0jZbeibwtTumcRbUSFadfXnCUClPMjL95_J6p5Y,2595
|
4
|
-
pygazpar/datasource.py,sha256=
|
4
|
+
pygazpar/datasource.py,sha256=nlIWxZ6SNSHf09BVBFIChSHf4dN05lC3LCxUUDRTylg,21470
|
5
5
|
pygazpar/enum.py,sha256=3ZCk4SziXF6pxgP3MuQ1qxYfqB3X5DOV8Rtd0GHsK9w,898
|
6
|
-
pygazpar/excelparser.py,sha256=
|
7
|
-
pygazpar/jsonparser.py,sha256=
|
8
|
-
pygazpar/version.py,sha256=
|
6
|
+
pygazpar/excelparser.py,sha256=glWlbj22pxYjHGKurOFmhzcVAoWCvfOHn7_Y6GgHUPo,5915
|
7
|
+
pygazpar/jsonparser.py,sha256=AWdU3h7UohsOov8HpeP8GNuqcnDmM4r3I7-CI_crDvA,1804
|
8
|
+
pygazpar/version.py,sha256=_dBppxmPi6eC2EiB3BcrYBcY9pm4iNlyhbySqBY4Y0Y,25
|
9
9
|
pygazpar/resources/daily_data_sample.json,sha256=YJovtrNUMs257magTfyxiewLmecySFypcelbGFUUeT8,199583
|
10
10
|
pygazpar/resources/hourly_data_sample.json,sha256=N1F-Xz3GaBn2H1p7uKzhkhKCQV8QVR0t76XD6wmFtXA,3
|
11
11
|
pygazpar/resources/monthly_data_sample.json,sha256=yrr4SqrB2MubeVU2HX_FRDZKHIhC0LXCqkO1iqnFWcg,3351
|
@@ -16,12 +16,12 @@ samples/excelSample.py,sha256=ltAl-bBz9-U9YI802JpcIswra-vDS7tR_KL5VNdxJ5c,765
|
|
16
16
|
samples/jsonSample.py,sha256=sYAIusdEJhZdwDAMgHqoWcwDR0FA2eWhSt_2gL_mJRk,736
|
17
17
|
samples/testSample.py,sha256=UeirdEtezHwfZDv_75oxul17YzGWn5yZuHfJYTF3Ez0,387
|
18
18
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
-
tests/test_client.py,sha256=
|
19
|
+
tests/test_client.py,sha256=DVGGubMPMM56LvQW-4_pCouvG9qTCbVZVPoRTBGuCU4,5111
|
20
20
|
tests/test_datafileparser.py,sha256=nAeUpOHtelblMpmbrrnf-2GuMjK5ai65veDoymceprE,818
|
21
|
-
tests/test_datasource.py,sha256=
|
22
|
-
pygazpar-1.
|
23
|
-
pygazpar-1.
|
24
|
-
pygazpar-1.
|
25
|
-
pygazpar-1.
|
26
|
-
pygazpar-1.
|
27
|
-
pygazpar-1.
|
21
|
+
tests/test_datasource.py,sha256=Fkn9BOGVKITAgrx9XipR1_ykT7rdvPyt_PAg3ftjfSU,5983
|
22
|
+
pygazpar-1.3.0a11.dist-info/LICENSE.md,sha256=XsCJx_7_BC9tvmE0ZxS1cTNR7ekurog_ea9ybdZ-8tc,1073
|
23
|
+
pygazpar-1.3.0a11.dist-info/METADATA,sha256=FhQCrz6r71ney7e9JmwTvJ-jnzVwIKSCbWk-3YqdL-Y,18417
|
24
|
+
pygazpar-1.3.0a11.dist-info/WHEEL,sha256=GbltxxgeSWIHDBy2twIuAtfZcwJlnEbPI_BIuEuGCR4,93
|
25
|
+
pygazpar-1.3.0a11.dist-info/entry_points.txt,sha256=dNJjC6RYY3FeJIe0hZL9Kcr6vKEx1qkZ71e6Slocb7I,52
|
26
|
+
pygazpar-1.3.0a11.dist-info/top_level.txt,sha256=P7qn-XtanDPBLQsTvjvLV71wH8RK0DYbx8tzN_rDS70,23
|
27
|
+
pygazpar-1.3.0a11.dist-info/RECORD,,
|
tests/test_client.py
CHANGED
@@ -1,159 +1,145 @@
|
|
1
|
-
from pygazpar.enum import Frequency
|
2
|
-
from pygazpar.client import Client
|
3
|
-
from pygazpar.datasource import JsonWebDataSource, TestDataSource, ExcelWebDataSource
|
4
|
-
import os
|
5
|
-
import pytest
|
6
|
-
|
7
|
-
|
8
|
-
class TestClient:
|
9
|
-
|
10
|
-
@classmethod
|
11
|
-
def setup_class(cls):
|
12
|
-
""" setup any state specific to the execution of the given class (which
|
13
|
-
usually contains tests).
|
14
|
-
"""
|
15
|
-
|
16
|
-
@classmethod
|
17
|
-
def teardown_class(cls):
|
18
|
-
""" teardown any state that was previously setup with a call to
|
19
|
-
setup_class.
|
20
|
-
"""
|
21
|
-
|
22
|
-
def setup_method(self):
|
23
|
-
""" setup any state tied to the execution of the given method in a
|
24
|
-
class. setup_method is invoked for every test method of a class.
|
25
|
-
"""
|
26
|
-
tmpdir = os.path.normpath(f"{os.getcwd()}/tmp")
|
27
|
-
|
28
|
-
# We create the tmp directory if not already exists.
|
29
|
-
if not os.path.exists(tmpdir):
|
30
|
-
os.mkdir(tmpdir)
|
31
|
-
|
32
|
-
self.__username = os.environ["GRDF_USERNAME"]
|
33
|
-
self.__password = os.environ["GRDF_PASSWORD"]
|
34
|
-
self.__pceIdentifier = os.environ["PCE_IDENTIFIER"]
|
35
|
-
self.__tmp_directory = tmpdir
|
36
|
-
|
37
|
-
def teardown_method(self):
|
38
|
-
""" teardown any state that was previously setup with a setup_method
|
39
|
-
call.
|
40
|
-
"""
|
41
|
-
|
42
|
-
def test_login_error(self):
|
43
|
-
client = Client(JsonWebDataSource("WrongUsername", "WrongPassword"))
|
44
|
-
|
45
|
-
with pytest.raises(Exception):
|
46
|
-
client.loadSince(self.__pceIdentifier, 365, [Frequency.DAILY])
|
47
|
-
|
48
|
-
def test_hourly_live(self):
|
49
|
-
client = Client(JsonWebDataSource(self.__username, self.__password))
|
50
|
-
|
51
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.HOURLY])
|
52
|
-
|
53
|
-
assert (len(data[Frequency.HOURLY.value]) == 0)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
def
|
71
|
-
client = Client(JsonWebDataSource(self.__username, self.__password))
|
72
|
-
|
73
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
74
|
-
|
75
|
-
assert (len(data[Frequency.
|
76
|
-
|
77
|
-
def
|
78
|
-
client = Client(JsonWebDataSource(self.__username, self.__password))
|
79
|
-
|
80
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
81
|
-
|
82
|
-
assert (len(data[Frequency.
|
83
|
-
|
84
|
-
def
|
85
|
-
client = Client(
|
86
|
-
|
87
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
88
|
-
|
89
|
-
assert (len(data[Frequency.
|
90
|
-
|
91
|
-
def
|
92
|
-
client = Client(
|
93
|
-
|
94
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
95
|
-
|
96
|
-
assert (len(data[Frequency.
|
97
|
-
|
98
|
-
def
|
99
|
-
client = Client(ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory))
|
100
|
-
|
101
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
102
|
-
|
103
|
-
assert (len(data[Frequency.
|
104
|
-
|
105
|
-
def
|
106
|
-
client = Client(ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory))
|
107
|
-
|
108
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
109
|
-
|
110
|
-
assert (len(data[Frequency.
|
111
|
-
|
112
|
-
def
|
113
|
-
client = Client(
|
114
|
-
|
115
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
116
|
-
|
117
|
-
assert (len(data[Frequency.
|
118
|
-
|
119
|
-
def
|
120
|
-
client = Client(
|
121
|
-
|
122
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
123
|
-
|
124
|
-
assert (len(data[Frequency.
|
125
|
-
|
126
|
-
def
|
127
|
-
client = Client(TestDataSource())
|
128
|
-
|
129
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
130
|
-
|
131
|
-
assert (len(data[Frequency.
|
132
|
-
|
133
|
-
def
|
134
|
-
client = Client(TestDataSource())
|
135
|
-
|
136
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
137
|
-
|
138
|
-
assert (len(data[Frequency.
|
139
|
-
|
140
|
-
def
|
141
|
-
client = Client(TestDataSource())
|
142
|
-
|
143
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.
|
144
|
-
|
145
|
-
assert (len(data[Frequency.
|
146
|
-
|
147
|
-
def test_monthly_sample(self):
|
148
|
-
client = Client(TestDataSource())
|
149
|
-
|
150
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.MONTHLY])
|
151
|
-
|
152
|
-
assert (len(data[Frequency.MONTHLY.value]) > 0)
|
153
|
-
|
154
|
-
def test_yearly_sample(self):
|
155
|
-
client = Client(TestDataSource())
|
156
|
-
|
157
|
-
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.YEARLY])
|
158
|
-
|
159
|
-
assert (len(data[Frequency.YEARLY.value]) == 2)
|
1
|
+
from pygazpar.enum import Frequency
|
2
|
+
from pygazpar.client import Client
|
3
|
+
from pygazpar.datasource import JsonWebDataSource, TestDataSource, ExcelWebDataSource
|
4
|
+
import os
|
5
|
+
import pytest
|
6
|
+
|
7
|
+
|
8
|
+
class TestClient:
|
9
|
+
|
10
|
+
@classmethod
|
11
|
+
def setup_class(cls):
|
12
|
+
""" setup any state specific to the execution of the given class (which
|
13
|
+
usually contains tests).
|
14
|
+
"""
|
15
|
+
|
16
|
+
@classmethod
|
17
|
+
def teardown_class(cls):
|
18
|
+
""" teardown any state that was previously setup with a call to
|
19
|
+
setup_class.
|
20
|
+
"""
|
21
|
+
|
22
|
+
def setup_method(self):
|
23
|
+
""" setup any state tied to the execution of the given method in a
|
24
|
+
class. setup_method is invoked for every test method of a class.
|
25
|
+
"""
|
26
|
+
tmpdir = os.path.normpath(f"{os.getcwd()}/tmp")
|
27
|
+
|
28
|
+
# We create the tmp directory if not already exists.
|
29
|
+
if not os.path.exists(tmpdir):
|
30
|
+
os.mkdir(tmpdir)
|
31
|
+
|
32
|
+
self.__username = os.environ["GRDF_USERNAME"]
|
33
|
+
self.__password = os.environ["GRDF_PASSWORD"]
|
34
|
+
self.__pceIdentifier = os.environ["PCE_IDENTIFIER"]
|
35
|
+
self.__tmp_directory = tmpdir
|
36
|
+
|
37
|
+
def teardown_method(self):
|
38
|
+
""" teardown any state that was previously setup with a setup_method
|
39
|
+
call.
|
40
|
+
"""
|
41
|
+
|
42
|
+
def test_login_error(self):
|
43
|
+
client = Client(JsonWebDataSource("WrongUsername", "WrongPassword"))
|
44
|
+
|
45
|
+
with pytest.raises(Exception):
|
46
|
+
client.loadSince(self.__pceIdentifier, 365, [Frequency.DAILY])
|
47
|
+
|
48
|
+
def test_hourly_live(self):
|
49
|
+
client = Client(JsonWebDataSource(self.__username, self.__password))
|
50
|
+
|
51
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.HOURLY])
|
52
|
+
|
53
|
+
assert (len(data[Frequency.HOURLY.value]) == 0)
|
54
|
+
|
55
|
+
# @pytest.mark.skip(reason="Requires live data")
|
56
|
+
def test_daily_jsonweb(self):
|
57
|
+
client = Client(JsonWebDataSource(self.__username, self.__password))
|
58
|
+
|
59
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.DAILY])
|
60
|
+
|
61
|
+
assert (len(data[Frequency.DAILY.value]) > 0)
|
62
|
+
|
63
|
+
def test_weekly_jsonweb(self):
|
64
|
+
client = Client(JsonWebDataSource(self.__username, self.__password))
|
65
|
+
|
66
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.WEEKLY])
|
67
|
+
|
68
|
+
assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54)
|
69
|
+
|
70
|
+
def test_monthly_jsonweb(self):
|
71
|
+
client = Client(JsonWebDataSource(self.__username, self.__password))
|
72
|
+
|
73
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.MONTHLY])
|
74
|
+
|
75
|
+
assert (len(data[Frequency.MONTHLY.value]) >= 11 and len(data[Frequency.MONTHLY.value]) <= 13)
|
76
|
+
|
77
|
+
def test_yearly_jsonweb(self):
|
78
|
+
client = Client(JsonWebDataSource(self.__username, self.__password))
|
79
|
+
|
80
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.YEARLY])
|
81
|
+
|
82
|
+
assert (len(data[Frequency.YEARLY.value]) == 1)
|
83
|
+
|
84
|
+
def test_daily_excelweb(self):
|
85
|
+
client = Client(ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory))
|
86
|
+
|
87
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.DAILY])
|
88
|
+
|
89
|
+
assert (len(data[Frequency.DAILY.value]) > 0)
|
90
|
+
|
91
|
+
def test_weekly_excelweb(self):
|
92
|
+
client = Client(ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory))
|
93
|
+
|
94
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.WEEKLY])
|
95
|
+
|
96
|
+
assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54)
|
97
|
+
|
98
|
+
def test_monthly_excelweb(self):
|
99
|
+
client = Client(ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory))
|
100
|
+
|
101
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.MONTHLY])
|
102
|
+
|
103
|
+
assert (len(data[Frequency.MONTHLY.value]) >= 12 and len(data[Frequency.MONTHLY.value]) <= 13)
|
104
|
+
|
105
|
+
def test_yearly_excelweb(self):
|
106
|
+
client = Client(ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory))
|
107
|
+
|
108
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.YEARLY])
|
109
|
+
|
110
|
+
assert (len(data[Frequency.YEARLY.value]) == 1)
|
111
|
+
|
112
|
+
def test_hourly_sample(self):
|
113
|
+
client = Client(TestDataSource())
|
114
|
+
|
115
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.HOURLY])
|
116
|
+
|
117
|
+
assert (len(data[Frequency.HOURLY.value]) == 0)
|
118
|
+
|
119
|
+
def test_daily_sample(self):
|
120
|
+
client = Client(TestDataSource())
|
121
|
+
|
122
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.DAILY])
|
123
|
+
|
124
|
+
assert (len(data[Frequency.DAILY.value]) == 711)
|
125
|
+
|
126
|
+
def test_weekly_sample(self):
|
127
|
+
client = Client(TestDataSource())
|
128
|
+
|
129
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.WEEKLY])
|
130
|
+
|
131
|
+
assert (len(data[Frequency.WEEKLY.value]) > 0)
|
132
|
+
|
133
|
+
def test_monthly_sample(self):
|
134
|
+
client = Client(TestDataSource())
|
135
|
+
|
136
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.MONTHLY])
|
137
|
+
|
138
|
+
assert (len(data[Frequency.MONTHLY.value]) > 0)
|
139
|
+
|
140
|
+
def test_yearly_sample(self):
|
141
|
+
client = Client(TestDataSource())
|
142
|
+
|
143
|
+
data = client.loadSince(self.__pceIdentifier, 365, [Frequency.YEARLY])
|
144
|
+
|
145
|
+
assert (len(data[Frequency.YEARLY.value]) == 2)
|
tests/test_datasource.py
CHANGED
@@ -1,166 +1,166 @@
|
|
1
|
-
import os
|
2
|
-
from pygazpar.datasource import TestDataSource, JsonFileDataSource, ExcelFileDataSource, JsonWebDataSource, ExcelWebDataSource
|
3
|
-
from pygazpar.enum import Frequency
|
4
|
-
from datetime import date, timedelta
|
5
|
-
from dotenv import load_dotenv
|
6
|
-
|
7
|
-
|
8
|
-
class TestAllDataSource:
|
9
|
-
|
10
|
-
# ------------------------------------------------------
|
11
|
-
@classmethod
|
12
|
-
def setup_class(cls):
|
13
|
-
""" setup any state specific to the execution of the given class (which
|
14
|
-
usually contains tests).
|
15
|
-
"""
|
16
|
-
|
17
|
-
# ------------------------------------------------------
|
18
|
-
@classmethod
|
19
|
-
def teardown_class(cls):
|
20
|
-
""" teardown any state that was previously setup with a call to
|
21
|
-
setup_class.
|
22
|
-
"""
|
23
|
-
|
24
|
-
# ------------------------------------------------------
|
25
|
-
def setup_method(self):
|
26
|
-
""" setup any state tied to the execution of the given method in a
|
27
|
-
class. setup_method is invoked for every test method of a class.
|
28
|
-
"""
|
29
|
-
tmpdir = os.path.normpath(f"{os.getcwd()}/tmp")
|
30
|
-
|
31
|
-
# We create the tmp directory if not already exists.
|
32
|
-
if not os.path.exists(tmpdir):
|
33
|
-
os.mkdir(tmpdir)
|
34
|
-
|
35
|
-
load_dotenv()
|
36
|
-
|
37
|
-
self.__username = os.environ["GRDF_USERNAME"]
|
38
|
-
self.__password = os.environ["GRDF_PASSWORD"]
|
39
|
-
self.__pceIdentifier = os.environ["PCE_IDENTIFIER"]
|
40
|
-
self.__tmp_directory = tmpdir
|
41
|
-
|
42
|
-
# ------------------------------------------------------
|
43
|
-
def teardown_method(self):
|
44
|
-
""" teardown any state that was previously setup with a setup_method
|
45
|
-
call.
|
46
|
-
"""
|
47
|
-
|
48
|
-
# ------------------------------------------------------
|
49
|
-
def test_sample(self):
|
50
|
-
|
51
|
-
dataSource = TestDataSource()
|
52
|
-
|
53
|
-
endDate = date.today()
|
54
|
-
startDate = endDate + timedelta(days=-365)
|
55
|
-
|
56
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate)
|
57
|
-
|
58
|
-
assert (len(data[Frequency.DAILY.value]) == 711)
|
59
|
-
|
60
|
-
assert (len(data[Frequency.WEEKLY.value]) == 102)
|
61
|
-
|
62
|
-
assert (len(data[Frequency.MONTHLY.value]) == 24)
|
63
|
-
|
64
|
-
assert (len(data[Frequency.YEARLY.value]) == 2)
|
65
|
-
|
66
|
-
# ------------------------------------------------------
|
67
|
-
def test_jsonfile_sample(self):
|
68
|
-
|
69
|
-
dataSource = JsonFileDataSource("tests/resources/donnees_informatives.json", "tests/resources/temperatures.json")
|
70
|
-
|
71
|
-
endDate = date.today()
|
72
|
-
startDate = endDate + timedelta(days=-365)
|
73
|
-
|
74
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY, Frequency.WEEKLY, Frequency.MONTHLY, Frequency.YEARLY])
|
75
|
-
|
76
|
-
assert (len(data[Frequency.DAILY.value]) == 1096)
|
77
|
-
|
78
|
-
assert (len(data[Frequency.WEEKLY.value]) == 155)
|
79
|
-
|
80
|
-
assert (len(data[Frequency.MONTHLY.value]) == 36)
|
81
|
-
|
82
|
-
assert (len(data[Frequency.YEARLY.value]) == 3)
|
83
|
-
|
84
|
-
# ------------------------------------------------------
|
85
|
-
def test_daily_excelfile_sample(self):
|
86
|
-
|
87
|
-
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_DAILY.xlsx")
|
88
|
-
|
89
|
-
endDate = date.today()
|
90
|
-
startDate = endDate + timedelta(days=-365)
|
91
|
-
|
92
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY])
|
93
|
-
|
94
|
-
assert (len(data[Frequency.DAILY.value]) == 363)
|
95
|
-
|
96
|
-
# ------------------------------------------------------
|
97
|
-
def test_weekly_excelfile_sample(self):
|
98
|
-
|
99
|
-
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_WEEKLY.xlsx")
|
100
|
-
|
101
|
-
endDate = date.today()
|
102
|
-
startDate = endDate + timedelta(days=-365)
|
103
|
-
|
104
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.WEEKLY])
|
105
|
-
|
106
|
-
assert (len(data[Frequency.WEEKLY.value]) == 53)
|
107
|
-
|
108
|
-
# ------------------------------------------------------
|
109
|
-
def test_monthly_excelfile_sample(self):
|
110
|
-
|
111
|
-
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_MONTHLY.xlsx")
|
112
|
-
|
113
|
-
endDate = date.today()
|
114
|
-
startDate = endDate + timedelta(days=-365)
|
115
|
-
|
116
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.MONTHLY])
|
117
|
-
|
118
|
-
assert (len(data[Frequency.MONTHLY.value]) == 13)
|
119
|
-
|
120
|
-
# ------------------------------------------------------
|
121
|
-
def test_yearly_excelfile_sample(self):
|
122
|
-
|
123
|
-
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_DAILY.xlsx")
|
124
|
-
|
125
|
-
endDate = date.today()
|
126
|
-
startDate = endDate + timedelta(days=-365)
|
127
|
-
|
128
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.YEARLY])
|
129
|
-
|
130
|
-
assert (len(data[Frequency.YEARLY.value]) == 1)
|
131
|
-
|
132
|
-
# ------------------------------------------------------
|
133
|
-
def test_jsonweb(self):
|
134
|
-
|
135
|
-
dataSource = JsonWebDataSource(self.__username, self.__password)
|
136
|
-
|
137
|
-
endDate = date.today()
|
138
|
-
startDate = endDate + timedelta(days=-365)
|
139
|
-
|
140
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY, Frequency.WEEKLY, Frequency.MONTHLY, Frequency.YEARLY])
|
141
|
-
|
142
|
-
assert (len(data[Frequency.DAILY.value]) > 0)
|
143
|
-
|
144
|
-
assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54)
|
145
|
-
|
146
|
-
assert (len(data[Frequency.MONTHLY.value]) >= 11 and len(data[Frequency.MONTHLY.value]) <= 13)
|
147
|
-
|
148
|
-
assert (len(data[Frequency.YEARLY.value])
|
149
|
-
|
150
|
-
# ------------------------------------------------------
|
151
|
-
def test_excelweb(self):
|
152
|
-
|
153
|
-
dataSource = ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory)
|
154
|
-
|
155
|
-
endDate = date.today()
|
156
|
-
startDate = endDate + timedelta(days=-365)
|
157
|
-
|
158
|
-
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY, Frequency.WEEKLY, Frequency.MONTHLY, Frequency.YEARLY])
|
159
|
-
|
160
|
-
assert (len(data[Frequency.DAILY.value]) > 0)
|
161
|
-
|
162
|
-
assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54)
|
163
|
-
|
164
|
-
assert (len(data[Frequency.MONTHLY.value]) >= 12 and len(data[Frequency.MONTHLY.value]) <= 13)
|
165
|
-
|
166
|
-
assert (len(data[Frequency.YEARLY.value])
|
1
|
+
import os
|
2
|
+
from pygazpar.datasource import TestDataSource, JsonFileDataSource, ExcelFileDataSource, JsonWebDataSource, ExcelWebDataSource
|
3
|
+
from pygazpar.enum import Frequency
|
4
|
+
from datetime import date, timedelta
|
5
|
+
from dotenv import load_dotenv
|
6
|
+
|
7
|
+
|
8
|
+
class TestAllDataSource:
|
9
|
+
|
10
|
+
# ------------------------------------------------------
|
11
|
+
@classmethod
|
12
|
+
def setup_class(cls):
|
13
|
+
""" setup any state specific to the execution of the given class (which
|
14
|
+
usually contains tests).
|
15
|
+
"""
|
16
|
+
|
17
|
+
# ------------------------------------------------------
|
18
|
+
@classmethod
|
19
|
+
def teardown_class(cls):
|
20
|
+
""" teardown any state that was previously setup with a call to
|
21
|
+
setup_class.
|
22
|
+
"""
|
23
|
+
|
24
|
+
# ------------------------------------------------------
|
25
|
+
def setup_method(self):
|
26
|
+
""" setup any state tied to the execution of the given method in a
|
27
|
+
class. setup_method is invoked for every test method of a class.
|
28
|
+
"""
|
29
|
+
tmpdir = os.path.normpath(f"{os.getcwd()}/tmp")
|
30
|
+
|
31
|
+
# We create the tmp directory if not already exists.
|
32
|
+
if not os.path.exists(tmpdir):
|
33
|
+
os.mkdir(tmpdir)
|
34
|
+
|
35
|
+
load_dotenv()
|
36
|
+
|
37
|
+
self.__username = os.environ["GRDF_USERNAME"]
|
38
|
+
self.__password = os.environ["GRDF_PASSWORD"]
|
39
|
+
self.__pceIdentifier = os.environ["PCE_IDENTIFIER"]
|
40
|
+
self.__tmp_directory = tmpdir
|
41
|
+
|
42
|
+
# ------------------------------------------------------
|
43
|
+
def teardown_method(self):
|
44
|
+
""" teardown any state that was previously setup with a setup_method
|
45
|
+
call.
|
46
|
+
"""
|
47
|
+
|
48
|
+
# ------------------------------------------------------
|
49
|
+
def test_sample(self):
|
50
|
+
|
51
|
+
dataSource = TestDataSource()
|
52
|
+
|
53
|
+
endDate = date.today()
|
54
|
+
startDate = endDate + timedelta(days=-365)
|
55
|
+
|
56
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate)
|
57
|
+
|
58
|
+
assert (len(data[Frequency.DAILY.value]) == 711)
|
59
|
+
|
60
|
+
assert (len(data[Frequency.WEEKLY.value]) == 102)
|
61
|
+
|
62
|
+
assert (len(data[Frequency.MONTHLY.value]) == 24)
|
63
|
+
|
64
|
+
assert (len(data[Frequency.YEARLY.value]) == 2)
|
65
|
+
|
66
|
+
# ------------------------------------------------------
|
67
|
+
def test_jsonfile_sample(self):
|
68
|
+
|
69
|
+
dataSource = JsonFileDataSource("tests/resources/donnees_informatives.json", "tests/resources/temperatures.json")
|
70
|
+
|
71
|
+
endDate = date.today()
|
72
|
+
startDate = endDate + timedelta(days=-365)
|
73
|
+
|
74
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY, Frequency.WEEKLY, Frequency.MONTHLY, Frequency.YEARLY])
|
75
|
+
|
76
|
+
assert (len(data[Frequency.DAILY.value]) == 1096)
|
77
|
+
|
78
|
+
assert (len(data[Frequency.WEEKLY.value]) == 155)
|
79
|
+
|
80
|
+
assert (len(data[Frequency.MONTHLY.value]) == 36)
|
81
|
+
|
82
|
+
assert (len(data[Frequency.YEARLY.value]) == 3)
|
83
|
+
|
84
|
+
# ------------------------------------------------------
|
85
|
+
def test_daily_excelfile_sample(self):
|
86
|
+
|
87
|
+
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_DAILY.xlsx")
|
88
|
+
|
89
|
+
endDate = date.today()
|
90
|
+
startDate = endDate + timedelta(days=-365)
|
91
|
+
|
92
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY])
|
93
|
+
|
94
|
+
assert (len(data[Frequency.DAILY.value]) == 363)
|
95
|
+
|
96
|
+
# ------------------------------------------------------
|
97
|
+
def test_weekly_excelfile_sample(self):
|
98
|
+
|
99
|
+
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_WEEKLY.xlsx")
|
100
|
+
|
101
|
+
endDate = date.today()
|
102
|
+
startDate = endDate + timedelta(days=-365)
|
103
|
+
|
104
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.WEEKLY])
|
105
|
+
|
106
|
+
assert (len(data[Frequency.WEEKLY.value]) == 53)
|
107
|
+
|
108
|
+
# ------------------------------------------------------
|
109
|
+
def test_monthly_excelfile_sample(self):
|
110
|
+
|
111
|
+
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_MONTHLY.xlsx")
|
112
|
+
|
113
|
+
endDate = date.today()
|
114
|
+
startDate = endDate + timedelta(days=-365)
|
115
|
+
|
116
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.MONTHLY])
|
117
|
+
|
118
|
+
assert (len(data[Frequency.MONTHLY.value]) == 13)
|
119
|
+
|
120
|
+
# ------------------------------------------------------
|
121
|
+
def test_yearly_excelfile_sample(self):
|
122
|
+
|
123
|
+
dataSource = ExcelFileDataSource("tests/resources/Donnees_informatives_PCE_DAILY.xlsx")
|
124
|
+
|
125
|
+
endDate = date.today()
|
126
|
+
startDate = endDate + timedelta(days=-365)
|
127
|
+
|
128
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.YEARLY])
|
129
|
+
|
130
|
+
assert (len(data[Frequency.YEARLY.value]) == 1)
|
131
|
+
|
132
|
+
# ------------------------------------------------------
|
133
|
+
def test_jsonweb(self):
|
134
|
+
|
135
|
+
dataSource = JsonWebDataSource(self.__username, self.__password)
|
136
|
+
|
137
|
+
endDate = date.today()
|
138
|
+
startDate = endDate + timedelta(days=-365)
|
139
|
+
|
140
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY, Frequency.WEEKLY, Frequency.MONTHLY, Frequency.YEARLY])
|
141
|
+
|
142
|
+
assert (len(data[Frequency.DAILY.value]) > 0)
|
143
|
+
|
144
|
+
assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54)
|
145
|
+
|
146
|
+
assert (len(data[Frequency.MONTHLY.value]) >= 11 and len(data[Frequency.MONTHLY.value]) <= 13)
|
147
|
+
|
148
|
+
assert (len(data[Frequency.YEARLY.value]) == 1)
|
149
|
+
|
150
|
+
# ------------------------------------------------------
|
151
|
+
def test_excelweb(self):
|
152
|
+
|
153
|
+
dataSource = ExcelWebDataSource(self.__username, self.__password, self.__tmp_directory)
|
154
|
+
|
155
|
+
endDate = date.today()
|
156
|
+
startDate = endDate + timedelta(days=-365)
|
157
|
+
|
158
|
+
data = dataSource.load(self.__pceIdentifier, startDate, endDate, [Frequency.DAILY, Frequency.WEEKLY, Frequency.MONTHLY, Frequency.YEARLY])
|
159
|
+
|
160
|
+
assert (len(data[Frequency.DAILY.value]) > 0)
|
161
|
+
|
162
|
+
assert (len(data[Frequency.WEEKLY.value]) >= 51 and len(data[Frequency.WEEKLY.value]) <= 54)
|
163
|
+
|
164
|
+
assert (len(data[Frequency.MONTHLY.value]) >= 12 and len(data[Frequency.MONTHLY.value]) <= 13)
|
165
|
+
|
166
|
+
assert (len(data[Frequency.YEARLY.value]) == 1)
|
File without changes
|
File without changes
|
File without changes
|