generated from marcieltorres/python-boilerplate-project
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add e2e-test for data + add .coveragerc
- Loading branch information
Showing
3 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[run] | ||
omit = tests/*, example.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import unittest | ||
from datetime import datetime, timedelta | ||
|
||
import aiohttp | ||
|
||
from iec_api.iec_client import IecClient | ||
from iec_api.models.jwt import JWT | ||
|
||
|
||
class CommonsTest(unittest.IsolatedAsyncioTestCase): | ||
jwt_token = { | ||
"access_token": "Fill", | ||
"refresh_token": "this", | ||
"token_type": "Bearer", | ||
"expires_in": 3600, | ||
"scope": "offline_access email openid profile", | ||
"id_token": "yourself", | ||
} | ||
|
||
async def test_e2e_with_existing_token(self): | ||
user_id = 123456782 | ||
session = aiohttp.ClientSession( | ||
connector=aiohttp.TCPConnector(ssl=False), timeout=aiohttp.ClientTimeout(total=10) | ||
) | ||
client = IecClient(session, user_id) | ||
await client.load_jwt_token(JWT.from_dict(self.jwt_token)) | ||
await client.check_token() | ||
await client.refresh_token() | ||
await client.save_token_to_file() | ||
|
||
await client.get_customer() | ||
await client.get_accounts() | ||
await client.get_default_account() | ||
await client.get_contracts() | ||
await client.get_default_contract() | ||
|
||
await client.get_device_type() | ||
devices = await client.get_devices() | ||
device = devices[0] | ||
await client.get_device_by_device_id(device_id=device.device_number) | ||
|
||
await client.get_billing_invoices() | ||
await client.get_electric_bill() | ||
await client.get_last_meter_reading() | ||
|
||
selected_date: datetime = datetime.now() - timedelta(days=30) | ||
|
||
await client.get_remote_reading(device.device_number, int(device.device_code), selected_date, selected_date) | ||
|
||
await client.save_token_to_file() | ||
await client.load_token_from_file() | ||
await client.check_token() | ||
await client.refresh_token() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |