fluves / pywaterinfo

Python package to download time series data from waterinfo.be
https://fluves.github.io/pywaterinfo/
MIT License
17 stars 9 forks source link

Add unit test for credit exceedance #22

Open stijnvanhoey opened 3 years ago

stijnvanhoey commented 3 years ago

For the VMM-case, we are allowed to use the test token with 0 credits for testing purposes:

test_0 hast 0 credits/day and should result in an error on the second call (the first call will exceed the allowance): YWNjNmFjOWYtZmVhNS00MmM5LWE4MWItZjZiMTk4NWE5ZGFjOmUzNWFjMjllLWIzMDQtNDY3My1iMGNjLWUyMTg0MmRjMDk2Mg== However, it does take some time for the system to recognize that a token is exhausted and even the token with 0 credits may work for some period of time after a first call has been made before errors start being returned.

So the following example makes fails by the second call:

from pywaterinfo import Waterinfo
vmm = Waterinfo("vmm", token="YWNjNmFjOWYtZmVhNS00MmM5LWE4MWItZjZiMTk4NWE5ZGFjOmUzNWFjMjllLWIzMDQtNDY3My1iMGNjLWUyMTg0MmRjMDk2Mg==")
vmm.get_timeseries_value_layer(timeseriesgroup_id="192786")
vmm.get_timeseries_value_layer(timeseriesgroup_id="192894")

Error message:

KiwisException: Waterinfo call returned 429 errorwith the message b'<?xml version="1.0" ?><ExceptionReport><Exception exceptionCode="AuthCreditLimit"><ExceptionText>Credit limit exceeded for type TOKEN and key acc6ac9f-fea5-42c9-a81b-f6b1985a9dac</ExceptionText></Exception></ExceptionReport>'