-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add test workflow --------- Co-authored-by: tr4nt0r <manni@zapto.de>
- Loading branch information
Showing
8 changed files
with
121 additions
and
2 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,24 @@ | ||
name: Test | ||
|
||
on: [ push, pull_request ] | ||
|
||
env: | ||
DEFAULT_PYTHON: "3.12" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4.1.1 | ||
- uses: actions/setup-python@v5.0.0 | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
check-latest: true | ||
- run: pip install -r requirements.txt | ||
- run: pip install python-dotenv | ||
- run: python test.py | ||
env: | ||
EMAIL: ${{ vars.EMAIL }} | ||
PASSWORD: ${{ secrets.PASSWORD }} | ||
LIST: ${{ vars.LIST }} | ||
|
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ test/ | |
.venv | ||
__pycache__ | ||
.ruff_cache | ||
.mypy_cache | ||
.mypy_cache | ||
.env |
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,24 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Python: Run Test", | ||
"type": "shell", | ||
"command": "${command:python.interpreterPath} test.py", | ||
"problemMatcher": [], | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
}, | ||
"presentation": { | ||
"focus": true, | ||
"reveal": "always" | ||
}, | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
} | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# CHANGELOG | ||
|
||
## 0.1.4 | ||
|
||
Add test workflow. | ||
|
||
## 0.1.3 | ||
|
||
Add mypy for type-checking. | ||
|
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
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,59 @@ | ||
"""Test script for Bring API.""" | ||
import asyncio | ||
import logging | ||
import os | ||
import sys | ||
|
||
import aiohttp | ||
from dotenv import load_dotenv | ||
|
||
from bring_api.bring import Bring | ||
from bring_api.types import BringList | ||
|
||
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) | ||
|
||
load_dotenv() | ||
|
||
|
||
async def test_add_complete_remove(bring: Bring, lst: BringList): | ||
"""Test add-complete-remove for an item.""" | ||
|
||
# Save an item with specifications to a certain shopping list | ||
await bring.saveItem(lst["listUuid"], "Äpfel", "low fat") | ||
|
||
# Get all the pending items of a list | ||
items = await bring.getItems(lst["listUuid"]) | ||
logging.info("List purchase items: %s", items["purchase"]) | ||
|
||
# Check of an item | ||
await bring.completeItem(lst["listUuid"], items["purchase"][0]["itemId"]) | ||
|
||
# Get all the recent items of a list | ||
items = await bring.getItems(lst["listUuid"]) | ||
logging.info("List recently items: %s", items["recently"]) | ||
|
||
# Remove an item from a list | ||
await bring.removeItem(lst["listUuid"], "Äpfel") | ||
|
||
# Get all the items of a list | ||
items = await bring.getItems(lst["listUuid"]) | ||
logging.info("List all items: %s / %s", items["purchase"], items["recently"]) | ||
|
||
|
||
async def main(): | ||
"""Test Bring API.""" | ||
async with aiohttp.ClientSession() as session: | ||
# Create Bring instance with email and password | ||
bring = Bring(session, os.environ["EMAIL"], os.environ["PASSWORD"]) | ||
# Login | ||
await bring.login() | ||
|
||
# Get information about all available shopping list and select one to test with | ||
lists = (await bring.loadLists())["lists"] | ||
lst = next(lst for lst in lists if lst["name"] == os.environ["LIST"]) | ||
logging.info("Selected list: %s (%s)", lst["name"], lst["listUuid"]) | ||
|
||
await test_add_complete_remove(bring, lst) | ||
|
||
|
||
asyncio.run(main()) |