kitchenowl-python 0.0.1__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kitchenowl_python-0.0.3/PKG-INFO +85 -0
- kitchenowl_python-0.0.3/pyproject.toml +188 -0
- kitchenowl_python-0.0.3/src/kitchenowl_python/py.typed +0 -0
- {kitchenowl_python-0.0.1 → kitchenowl_python-0.0.3}/src/kitchenowl_python/types.py +6 -6
- kitchenowl_python-0.0.1/PKG-INFO +0 -87
- kitchenowl_python-0.0.1/pyproject.toml +0 -195
- kitchenowl_python-0.0.1/setup.cfg +0 -4
- kitchenowl_python-0.0.1/src/kitchenowl_python.egg-info/PKG-INFO +0 -87
- kitchenowl_python-0.0.1/src/kitchenowl_python.egg-info/SOURCES.txt +0 -14
- kitchenowl_python-0.0.1/src/kitchenowl_python.egg-info/dependency_links.txt +0 -1
- kitchenowl_python-0.0.1/src/kitchenowl_python.egg-info/requires.txt +0 -11
- kitchenowl_python-0.0.1/src/kitchenowl_python.egg-info/top_level.txt +0 -1
- kitchenowl_python-0.0.1/tests/test_kitchenowl.py +0 -547
- {kitchenowl_python-0.0.1 → kitchenowl_python-0.0.3}/LICENSE +0 -0
- {kitchenowl_python-0.0.1 → kitchenowl_python-0.0.3}/README.md +0 -0
- {kitchenowl_python-0.0.1 → kitchenowl_python-0.0.3}/src/kitchenowl_python/__init__.py +0 -0
- {kitchenowl_python-0.0.1 → kitchenowl_python-0.0.3}/src/kitchenowl_python/const.py +0 -0
- {kitchenowl_python-0.0.1 → kitchenowl_python-0.0.3}/src/kitchenowl_python/exceptions.py +0 -0
- {kitchenowl_python-0.0.1 → kitchenowl_python-0.0.3}/src/kitchenowl_python/kitchenowl.py +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: kitchenowl-python
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: A python wrapper for the KitchenOwl API
|
|
5
|
+
Keywords: kitchenowl
|
|
6
|
+
Author: Tom Bursch, super-qua
|
|
7
|
+
Author-email: Tom Bursch <tom@kitchenowl.org>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2024 super-qua, Tom Bursch
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Programming Language :: Python
|
|
31
|
+
Requires-Dist: aiohttp>=3.11.11
|
|
32
|
+
Requires-Dist: ruff>=0.9.4 ; extra == 'lint'
|
|
33
|
+
Requires-Dist: aioresponses>=0.7.8 ; extra == 'test'
|
|
34
|
+
Requires-Dist: pytest>=8.3.4 ; extra == 'test'
|
|
35
|
+
Requires-Dist: pytest-asyncio>=0.25.3 ; extra == 'test'
|
|
36
|
+
Requires-Dist: pytest-cov>=6.0.0 ; extra == 'test'
|
|
37
|
+
Requires-Dist: syrupy>=4.8.1 ; extra == 'test'
|
|
38
|
+
Requires-Python: >=3.12
|
|
39
|
+
Project-URL: Homepage, https://kitchenowl.org
|
|
40
|
+
Project-URL: Repository, https://github.com/tombursch/kitchenowl-python
|
|
41
|
+
Project-URL: Issues, https://github.com/TomBursch/kitchenowl/issues
|
|
42
|
+
Project-URL: Changelog, https://github.com/tombursch/kitchenowl-python/blob/main/CHANGELOG.md
|
|
43
|
+
Provides-Extra: lint
|
|
44
|
+
Provides-Extra: test
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# kitchenowl-python
|
|
48
|
+
A simple wrapper around the KitchenOwl API.
|
|
49
|
+
|
|
50
|
+
This is a small python package to be used as a wrapper for the KitchenOwl API in python.
|
|
51
|
+
|
|
52
|
+
Currently, there is only support for managing shopping list items.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
python -m venv .venv
|
|
58
|
+
source .venv/bin/activate
|
|
59
|
+
pip install -e .
|
|
60
|
+
```
|
|
61
|
+
Installs all required dependencies.
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from aiohttp import ClientSession
|
|
67
|
+
from kitchenowl_python.kitchenowl import KitchenOwl
|
|
68
|
+
|
|
69
|
+
async with ClientSession() as session:
|
|
70
|
+
kitchenowl = KitchenOwl(session=session, url=url, token=token)
|
|
71
|
+
await kitchenowl.test_connection()
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
### Run tests
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
source .venv/bin/activate
|
|
81
|
+
pip install -e .\[test\]
|
|
82
|
+
pytest .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "kitchenowl-python"
|
|
3
|
+
description = "A python wrapper for the KitchenOwl API"
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
keywords = ["kitchenowl"]
|
|
6
|
+
version = "0.0.3"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Tom Bursch", email = "tom@kitchenowl.org" },
|
|
9
|
+
{ name = "super-qua" },
|
|
10
|
+
]
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Programming Language :: Python",
|
|
15
|
+
]
|
|
16
|
+
dependencies = ["aiohttp >= 3.11.11"]
|
|
17
|
+
requires-python = ">=3.12"
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
test = [
|
|
21
|
+
"aioresponses >= 0.7.8",
|
|
22
|
+
"pytest >= 8.3.4",
|
|
23
|
+
"pytest-asyncio >= 0.25.3",
|
|
24
|
+
"pytest-cov >= 6.0.0",
|
|
25
|
+
"syrupy >= 4.8.1",
|
|
26
|
+
]
|
|
27
|
+
lint = ["ruff >= 0.9.4"]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://kitchenowl.org"
|
|
31
|
+
Repository = "https://github.com/tombursch/kitchenowl-python"
|
|
32
|
+
Issues = "https://github.com/TomBursch/kitchenowl/issues"
|
|
33
|
+
Changelog = "https://github.com/tombursch/kitchenowl-python/blob/main/CHANGELOG.md"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["uv_build>=0.11.3,<0.12"]
|
|
37
|
+
build-backend = "uv_build"
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
minversion = 6.0
|
|
41
|
+
pythonpath = "src"
|
|
42
|
+
asyncio_mode = "auto"
|
|
43
|
+
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 100
|
|
47
|
+
indent-width = 4
|
|
48
|
+
|
|
49
|
+
[tool.ruff.format]
|
|
50
|
+
quote-style = "double"
|
|
51
|
+
indent-style = "space"
|
|
52
|
+
line-ending = "auto"
|
|
53
|
+
|
|
54
|
+
[tool.ruff.lint]
|
|
55
|
+
# linter rules copied from https://github.com/home-assistant/core/blob/dev/pyproject.toml
|
|
56
|
+
select = [
|
|
57
|
+
"A001", # Variable {name} is shadowing a Python builtin
|
|
58
|
+
"ASYNC210", # Async functions should not call blocking HTTP methods
|
|
59
|
+
"ASYNC220", # Async functions should not create subprocesses with blocking methods
|
|
60
|
+
"ASYNC221", # Async functions should not run processes with blocking methods
|
|
61
|
+
"ASYNC222", # Async functions should not wait on processes with blocking methods
|
|
62
|
+
"ASYNC230", # Async functions should not open files with blocking methods like open
|
|
63
|
+
"ASYNC251", # Async functions should not call time.sleep
|
|
64
|
+
"B002", # Python does not support the unary prefix increment
|
|
65
|
+
"B005", # Using .strip() with multi-character strings is misleading
|
|
66
|
+
"B007", # Loop control variable {name} not used within loop body
|
|
67
|
+
"B014", # Exception handler with duplicate exception
|
|
68
|
+
"B015", # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it.
|
|
69
|
+
"B017", # pytest.raises(BaseException) should be considered evil
|
|
70
|
+
"B018", # Found useless attribute access. Either assign it to a variable or remove it.
|
|
71
|
+
"B023", # Function definition does not bind loop variable {name}
|
|
72
|
+
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
|
|
73
|
+
"B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)?
|
|
74
|
+
"B904", # Use raise from to specify exception cause
|
|
75
|
+
"B905", # zip() without an explicit strict= parameter
|
|
76
|
+
"BLE",
|
|
77
|
+
"C", # complexity
|
|
78
|
+
"COM818", # Trailing comma on bare tuple prohibited
|
|
79
|
+
"D", # docstrings
|
|
80
|
+
"DTZ003", # Use datetime.now(tz=) instead of datetime.utcnow()
|
|
81
|
+
"DTZ004", # Use datetime.fromtimestamp(ts, tz=) instead of datetime.utcfromtimestamp(ts)
|
|
82
|
+
"E", # pycodestyle
|
|
83
|
+
"F", # pyflakes/autoflake
|
|
84
|
+
"FLY", # flynt
|
|
85
|
+
"FURB", # refurb
|
|
86
|
+
"G", # flake8-logging-format
|
|
87
|
+
"I", # isort
|
|
88
|
+
"INP", # flake8-no-pep420
|
|
89
|
+
"ISC", # flake8-implicit-str-concat
|
|
90
|
+
"ICN001", # import concentions; {name} should be imported as {asname}
|
|
91
|
+
"LOG", # flake8-logging
|
|
92
|
+
"N804", # First argument of a class method should be named cls
|
|
93
|
+
"N805", # First argument of a method should be named self
|
|
94
|
+
"N815", # Variable {name} in class scope should not be mixedCase
|
|
95
|
+
"PERF", # Perflint
|
|
96
|
+
"PGH", # pygrep-hooks
|
|
97
|
+
"PIE", # flake8-pie
|
|
98
|
+
"PL", # pylint
|
|
99
|
+
"PT", # flake8-pytest-style
|
|
100
|
+
"PYI", # flake8-pyi
|
|
101
|
+
"RET", # flake8-return
|
|
102
|
+
"RSE", # flake8-raise
|
|
103
|
+
"RUF005", # Consider iterable unpacking instead of concatenation
|
|
104
|
+
"RUF006", # Store a reference to the return value of asyncio.create_task
|
|
105
|
+
"RUF010", # Use explicit conversion flag
|
|
106
|
+
"RUF013", # PEP 484 prohibits implicit Optional
|
|
107
|
+
"RUF017", # Avoid quadratic list summation
|
|
108
|
+
"RUF018", # Avoid assignment expressions in assert statements
|
|
109
|
+
"RUF019", # Unnecessary key check before dictionary access
|
|
110
|
+
# "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up
|
|
111
|
+
"S102", # Use of exec detected
|
|
112
|
+
"S103", # bad-file-permissions
|
|
113
|
+
"S108", # hardcoded-temp-file
|
|
114
|
+
"S306", # suspicious-mktemp-usage
|
|
115
|
+
"S307", # suspicious-eval-usage
|
|
116
|
+
"S313", # suspicious-xmlc-element-tree-usage
|
|
117
|
+
"S314", # suspicious-xml-element-tree-usage
|
|
118
|
+
"S315", # suspicious-xml-expat-reader-usage
|
|
119
|
+
"S316", # suspicious-xml-expat-builder-usage
|
|
120
|
+
"S317", # suspicious-xml-sax-usage
|
|
121
|
+
"S318", # suspicious-xml-mini-dom-usage
|
|
122
|
+
"S319", # suspicious-xml-pull-dom-usage
|
|
123
|
+
"S601", # paramiko-call
|
|
124
|
+
"S602", # subprocess-popen-with-shell-equals-true
|
|
125
|
+
"S604", # call-with-shell-equals-true
|
|
126
|
+
"S608", # hardcoded-sql-expression
|
|
127
|
+
"S609", # unix-command-wildcard-injection
|
|
128
|
+
"SIM", # flake8-simplify
|
|
129
|
+
"SLF", # flake8-self
|
|
130
|
+
"SLOT", # flake8-slots
|
|
131
|
+
"T100", # Trace found: {name} used
|
|
132
|
+
"T20", # flake8-print
|
|
133
|
+
"TID251", # Banned imports
|
|
134
|
+
"TRY", # tryceratops
|
|
135
|
+
"UP", # pyupgrade
|
|
136
|
+
"W", # pycodestyle
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
ignore = [
|
|
140
|
+
"D202", # No blank lines allowed after function docstring
|
|
141
|
+
"D203", # 1 blank line required before class docstring
|
|
142
|
+
"D213", # Multi-line docstring summary should start at the second line
|
|
143
|
+
"D406", # Section name should end with a newline
|
|
144
|
+
"D407", # Section name underlining
|
|
145
|
+
"E501", # line too long
|
|
146
|
+
|
|
147
|
+
"PLC1901", # {existing} can be simplified to {replacement} as an empty string is falsey; too many false positives
|
|
148
|
+
"PLR0911", # Too many return statements ({returns} > {max_returns})
|
|
149
|
+
"PLR0912", # Too many branches ({branches} > {max_branches})
|
|
150
|
+
"PLR0913", # Too many arguments to function call ({c_args} > {max_args})
|
|
151
|
+
"PLR0915", # Too many statements ({statements} > {max_statements})
|
|
152
|
+
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
|
|
153
|
+
"PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
|
|
154
|
+
"PT011", # pytest.raises({exception}) is too broad, set the `match` parameter or use a more specific exception
|
|
155
|
+
"PT018", # Assertion should be broken down into multiple parts
|
|
156
|
+
"RUF001", # String contains ambiguous unicode character.
|
|
157
|
+
"RUF002", # Docstring contains ambiguous unicode character.
|
|
158
|
+
"RUF003", # Comment contains ambiguous unicode character.
|
|
159
|
+
"RUF015", # Prefer next(...) over single element slice
|
|
160
|
+
"SIM102", # Use a single if statement instead of nested if statements
|
|
161
|
+
"SIM103", # Return the condition {condition} directly
|
|
162
|
+
"SIM108", # Use ternary operator {contents} instead of if-else-block
|
|
163
|
+
"SIM115", # Use context handler for opening files
|
|
164
|
+
"TRY003", # Avoid specifying long messages outside the exception class
|
|
165
|
+
"TRY400", # Use `logging.exception` instead of `logging.error`
|
|
166
|
+
|
|
167
|
+
# May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
|
|
168
|
+
"W191",
|
|
169
|
+
"E111",
|
|
170
|
+
"E114",
|
|
171
|
+
"E117",
|
|
172
|
+
"D206",
|
|
173
|
+
"D300",
|
|
174
|
+
"Q",
|
|
175
|
+
"COM812",
|
|
176
|
+
"COM819",
|
|
177
|
+
"ISC001",
|
|
178
|
+
|
|
179
|
+
# Disabled because ruff does not understand type of __all__ generated by a function
|
|
180
|
+
"PLE0605",
|
|
181
|
+
|
|
182
|
+
# temporarily disabled
|
|
183
|
+
"RET503",
|
|
184
|
+
"TRY301",
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
[tool.ruff.lint.pydocstyle]
|
|
188
|
+
convention = "google"
|
|
File without changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# TypedDict for now as it allows for changes in the API return values
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import NotRequired, TypedDict
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class KitchenOwlShoppingListCategory(TypedDict):
|
|
@@ -73,21 +73,21 @@ class KitchenOwlHousehold(TypedDict):
|
|
|
73
73
|
expenses_feature: bool
|
|
74
74
|
id: int
|
|
75
75
|
language: str
|
|
76
|
-
member:
|
|
76
|
+
member: list[KitchenOwlUser]
|
|
77
77
|
name: str
|
|
78
78
|
photo: str | None
|
|
79
79
|
planner_feature: bool
|
|
80
80
|
updated_at: int
|
|
81
|
-
view_ordering:
|
|
81
|
+
view_ordering: list[str]
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
class KitchenOwlHouseholdsResponse(
|
|
84
|
+
class KitchenOwlHouseholdsResponse(list[KitchenOwlHousehold]):
|
|
85
85
|
"""The households response from KitchenOwl."""
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
class KitchenOwlShoppingListsResponse(
|
|
88
|
+
class KitchenOwlShoppingListsResponse(list[KitchenOwlShoppingList]):
|
|
89
89
|
"""The shopping lists response from KitchenOwl."""
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
class KitchenOwlShoppingListItemsResponse(
|
|
92
|
+
class KitchenOwlShoppingListItemsResponse(list[KitchenOwlShoppingListItem]):
|
|
93
93
|
"""The response for shopping list items from KitchenOwl."""
|
kitchenowl_python-0.0.1/PKG-INFO
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: kitchenowl-python
|
|
3
|
-
Version: 0.0.1
|
|
4
|
-
Summary: A python wrapper for the KitchenOwl API
|
|
5
|
-
Author: super-qua
|
|
6
|
-
Author-email: Tom Bursch <tom@kitchenowl.org>
|
|
7
|
-
License: MIT License
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2024 super-qua, Tom Bursch
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
|
|
29
|
-
Project-URL: Homepage, https://kitchenowl.org
|
|
30
|
-
Project-URL: Repository, https://github.com/tombursch/kitchenowl-python
|
|
31
|
-
Project-URL: Issues, https://github.com/TomBursch/kitchenowl/issues
|
|
32
|
-
Project-URL: Changelog, https://github.com/tombursch/kitchenowl-python/blob/main/CHANGELOG.md
|
|
33
|
-
Keywords: kitchenowl
|
|
34
|
-
Classifier: Development Status :: 3 - Alpha
|
|
35
|
-
Classifier: Programming Language :: Python
|
|
36
|
-
Requires-Python: >=3.8
|
|
37
|
-
Description-Content-Type: text/markdown
|
|
38
|
-
License-File: LICENSE
|
|
39
|
-
Requires-Dist: aiohttp==3.10.5
|
|
40
|
-
Provides-Extra: test
|
|
41
|
-
Requires-Dist: aioresponses==0.7.6; extra == "test"
|
|
42
|
-
Requires-Dist: pytest==8.2.2; extra == "test"
|
|
43
|
-
Requires-Dist: pytest-asyncio==0.23.7; extra == "test"
|
|
44
|
-
Requires-Dist: pytest-cov==6.0.0; extra == "test"
|
|
45
|
-
Requires-Dist: syrupy==4.6.1; extra == "test"
|
|
46
|
-
Provides-Extra: lint
|
|
47
|
-
Requires-Dist: ruff==0.6.1; extra == "lint"
|
|
48
|
-
|
|
49
|
-
# kitchenowl-python
|
|
50
|
-
A simple wrapper around the KitchenOwl API.
|
|
51
|
-
|
|
52
|
-
This is a small python package to be used as a wrapper for the KitchenOwl API in python.
|
|
53
|
-
|
|
54
|
-
Currently, there is only support for managing shopping list items.
|
|
55
|
-
|
|
56
|
-
## Installation
|
|
57
|
-
|
|
58
|
-
```shell
|
|
59
|
-
python -m venv .venv
|
|
60
|
-
source .venv/bin/activate
|
|
61
|
-
pip install -e .
|
|
62
|
-
```
|
|
63
|
-
Installs all required dependencies.
|
|
64
|
-
|
|
65
|
-
## Usage
|
|
66
|
-
|
|
67
|
-
```python
|
|
68
|
-
from aiohttp import ClientSession
|
|
69
|
-
from kitchenowl_python.kitchenowl import KitchenOwl
|
|
70
|
-
|
|
71
|
-
async with ClientSession() as session:
|
|
72
|
-
kitchenowl = KitchenOwl(session=session, url=url, token=token)
|
|
73
|
-
await kitchenowl.test_connection()
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Development
|
|
78
|
-
|
|
79
|
-
### Run tests
|
|
80
|
-
|
|
81
|
-
```shell
|
|
82
|
-
source .venv/bin/activate
|
|
83
|
-
pip install -e .\[test\]
|
|
84
|
-
pytest .
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "kitchenowl-python"
|
|
3
|
-
description = "A python wrapper for the KitchenOwl API"
|
|
4
|
-
readme = "README.md"
|
|
5
|
-
keywords = ["kitchenowl"]
|
|
6
|
-
version = "0.0.1"
|
|
7
|
-
authors = [
|
|
8
|
-
{name = "Tom Bursch", email = "tom@kitchenowl.org"},
|
|
9
|
-
{name = "super-qua"},
|
|
10
|
-
]
|
|
11
|
-
license = {file = "LICENSE"}
|
|
12
|
-
classifiers = [
|
|
13
|
-
"Development Status :: 3 - Alpha",
|
|
14
|
-
"Programming Language :: Python"
|
|
15
|
-
]
|
|
16
|
-
dependencies = [
|
|
17
|
-
"aiohttp == 3.10.5"
|
|
18
|
-
]
|
|
19
|
-
requires-python = ">=3.8"
|
|
20
|
-
|
|
21
|
-
[project.optional-dependencies]
|
|
22
|
-
test = [
|
|
23
|
-
"aioresponses == 0.7.6",
|
|
24
|
-
"pytest == 8.2.2",
|
|
25
|
-
"pytest-asyncio == 0.23.7",
|
|
26
|
-
"pytest-cov==6.0.0",
|
|
27
|
-
"syrupy == 4.6.1"
|
|
28
|
-
]
|
|
29
|
-
lint = [
|
|
30
|
-
"ruff == 0.6.1"
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
[project.urls]
|
|
34
|
-
Homepage = "https://kitchenowl.org"
|
|
35
|
-
Repository = "https://github.com/tombursch/kitchenowl-python"
|
|
36
|
-
Issues = "https://github.com/TomBursch/kitchenowl/issues"
|
|
37
|
-
Changelog = "https://github.com/tombursch/kitchenowl-python/blob/main/CHANGELOG.md"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
[tool.pytest.ini_options]
|
|
41
|
-
minversion = 6.0
|
|
42
|
-
pythonpath = "src"
|
|
43
|
-
asyncio_mode = "auto"
|
|
44
|
-
markers = [
|
|
45
|
-
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
46
|
-
]
|
|
47
|
-
|
|
48
|
-
[tool.ruff]
|
|
49
|
-
line-length = 100
|
|
50
|
-
indent-width = 4
|
|
51
|
-
|
|
52
|
-
[tool.ruff.format]
|
|
53
|
-
quote-style = "double"
|
|
54
|
-
indent-style = "space"
|
|
55
|
-
line-ending = "auto"
|
|
56
|
-
|
|
57
|
-
[tool.ruff.lint]
|
|
58
|
-
# linter rules copied from https://github.com/home-assistant/core/blob/dev/pyproject.toml
|
|
59
|
-
select = [
|
|
60
|
-
"A001", # Variable {name} is shadowing a Python builtin
|
|
61
|
-
"ASYNC210", # Async functions should not call blocking HTTP methods
|
|
62
|
-
"ASYNC220", # Async functions should not create subprocesses with blocking methods
|
|
63
|
-
"ASYNC221", # Async functions should not run processes with blocking methods
|
|
64
|
-
"ASYNC222", # Async functions should not wait on processes with blocking methods
|
|
65
|
-
"ASYNC230", # Async functions should not open files with blocking methods like open
|
|
66
|
-
"ASYNC251", # Async functions should not call time.sleep
|
|
67
|
-
"B002", # Python does not support the unary prefix increment
|
|
68
|
-
"B005", # Using .strip() with multi-character strings is misleading
|
|
69
|
-
"B007", # Loop control variable {name} not used within loop body
|
|
70
|
-
"B014", # Exception handler with duplicate exception
|
|
71
|
-
"B015", # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it.
|
|
72
|
-
"B017", # pytest.raises(BaseException) should be considered evil
|
|
73
|
-
"B018", # Found useless attribute access. Either assign it to a variable or remove it.
|
|
74
|
-
"B023", # Function definition does not bind loop variable {name}
|
|
75
|
-
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
|
|
76
|
-
"B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)?
|
|
77
|
-
"B904", # Use raise from to specify exception cause
|
|
78
|
-
"B905", # zip() without an explicit strict= parameter
|
|
79
|
-
"BLE",
|
|
80
|
-
"C", # complexity
|
|
81
|
-
"COM818", # Trailing comma on bare tuple prohibited
|
|
82
|
-
"D", # docstrings
|
|
83
|
-
"DTZ003", # Use datetime.now(tz=) instead of datetime.utcnow()
|
|
84
|
-
"DTZ004", # Use datetime.fromtimestamp(ts, tz=) instead of datetime.utcfromtimestamp(ts)
|
|
85
|
-
"E", # pycodestyle
|
|
86
|
-
"F", # pyflakes/autoflake
|
|
87
|
-
"FLY", # flynt
|
|
88
|
-
"FURB", # refurb
|
|
89
|
-
"G", # flake8-logging-format
|
|
90
|
-
"I", # isort
|
|
91
|
-
"INP", # flake8-no-pep420
|
|
92
|
-
"ISC", # flake8-implicit-str-concat
|
|
93
|
-
"ICN001", # import concentions; {name} should be imported as {asname}
|
|
94
|
-
"LOG", # flake8-logging
|
|
95
|
-
"N804", # First argument of a class method should be named cls
|
|
96
|
-
"N805", # First argument of a method should be named self
|
|
97
|
-
"N815", # Variable {name} in class scope should not be mixedCase
|
|
98
|
-
"PERF", # Perflint
|
|
99
|
-
"PGH", # pygrep-hooks
|
|
100
|
-
"PIE", # flake8-pie
|
|
101
|
-
"PL", # pylint
|
|
102
|
-
"PT", # flake8-pytest-style
|
|
103
|
-
"PYI", # flake8-pyi
|
|
104
|
-
"RET", # flake8-return
|
|
105
|
-
"RSE", # flake8-raise
|
|
106
|
-
"RUF005", # Consider iterable unpacking instead of concatenation
|
|
107
|
-
"RUF006", # Store a reference to the return value of asyncio.create_task
|
|
108
|
-
"RUF010", # Use explicit conversion flag
|
|
109
|
-
"RUF013", # PEP 484 prohibits implicit Optional
|
|
110
|
-
"RUF017", # Avoid quadratic list summation
|
|
111
|
-
"RUF018", # Avoid assignment expressions in assert statements
|
|
112
|
-
"RUF019", # Unnecessary key check before dictionary access
|
|
113
|
-
# "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up
|
|
114
|
-
"S102", # Use of exec detected
|
|
115
|
-
"S103", # bad-file-permissions
|
|
116
|
-
"S108", # hardcoded-temp-file
|
|
117
|
-
"S306", # suspicious-mktemp-usage
|
|
118
|
-
"S307", # suspicious-eval-usage
|
|
119
|
-
"S313", # suspicious-xmlc-element-tree-usage
|
|
120
|
-
"S314", # suspicious-xml-element-tree-usage
|
|
121
|
-
"S315", # suspicious-xml-expat-reader-usage
|
|
122
|
-
"S316", # suspicious-xml-expat-builder-usage
|
|
123
|
-
"S317", # suspicious-xml-sax-usage
|
|
124
|
-
"S318", # suspicious-xml-mini-dom-usage
|
|
125
|
-
"S319", # suspicious-xml-pull-dom-usage
|
|
126
|
-
"S320", # suspicious-xmle-tree-usage
|
|
127
|
-
"S601", # paramiko-call
|
|
128
|
-
"S602", # subprocess-popen-with-shell-equals-true
|
|
129
|
-
"S604", # call-with-shell-equals-true
|
|
130
|
-
"S608", # hardcoded-sql-expression
|
|
131
|
-
"S609", # unix-command-wildcard-injection
|
|
132
|
-
"SIM", # flake8-simplify
|
|
133
|
-
"SLF", # flake8-self
|
|
134
|
-
"SLOT", # flake8-slots
|
|
135
|
-
"T100", # Trace found: {name} used
|
|
136
|
-
"T20", # flake8-print
|
|
137
|
-
"TID251", # Banned imports
|
|
138
|
-
"TRY", # tryceratops
|
|
139
|
-
"UP", # pyupgrade
|
|
140
|
-
"W", # pycodestyle
|
|
141
|
-
]
|
|
142
|
-
|
|
143
|
-
ignore = [
|
|
144
|
-
"D202", # No blank lines allowed after function docstring
|
|
145
|
-
"D203", # 1 blank line required before class docstring
|
|
146
|
-
"D213", # Multi-line docstring summary should start at the second line
|
|
147
|
-
"D406", # Section name should end with a newline
|
|
148
|
-
"D407", # Section name underlining
|
|
149
|
-
"E501", # line too long
|
|
150
|
-
|
|
151
|
-
"PLC1901", # {existing} can be simplified to {replacement} as an empty string is falsey; too many false positives
|
|
152
|
-
"PLR0911", # Too many return statements ({returns} > {max_returns})
|
|
153
|
-
"PLR0912", # Too many branches ({branches} > {max_branches})
|
|
154
|
-
"PLR0913", # Too many arguments to function call ({c_args} > {max_args})
|
|
155
|
-
"PLR0915", # Too many statements ({statements} > {max_statements})
|
|
156
|
-
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
|
|
157
|
-
"PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
|
|
158
|
-
"PT004", # Fixture {fixture} does not return anything, add leading underscore
|
|
159
|
-
"PT011", # pytest.raises({exception}) is too broad, set the `match` parameter or use a more specific exception
|
|
160
|
-
"PT018", # Assertion should be broken down into multiple parts
|
|
161
|
-
"RUF001", # String contains ambiguous unicode character.
|
|
162
|
-
"RUF002", # Docstring contains ambiguous unicode character.
|
|
163
|
-
"RUF003", # Comment contains ambiguous unicode character.
|
|
164
|
-
"RUF015", # Prefer next(...) over single element slice
|
|
165
|
-
"SIM102", # Use a single if statement instead of nested if statements
|
|
166
|
-
"SIM103", # Return the condition {condition} directly
|
|
167
|
-
"SIM108", # Use ternary operator {contents} instead of if-else-block
|
|
168
|
-
"SIM115", # Use context handler for opening files
|
|
169
|
-
"TRY003", # Avoid specifying long messages outside the exception class
|
|
170
|
-
"TRY400", # Use `logging.exception` instead of `logging.error`
|
|
171
|
-
# Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923
|
|
172
|
-
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
|
|
173
|
-
|
|
174
|
-
# May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
|
|
175
|
-
"W191",
|
|
176
|
-
"E111",
|
|
177
|
-
"E114",
|
|
178
|
-
"E117",
|
|
179
|
-
"D206",
|
|
180
|
-
"D300",
|
|
181
|
-
"Q",
|
|
182
|
-
"COM812",
|
|
183
|
-
"COM819",
|
|
184
|
-
"ISC001",
|
|
185
|
-
|
|
186
|
-
# Disabled because ruff does not understand type of __all__ generated by a function
|
|
187
|
-
"PLE0605",
|
|
188
|
-
|
|
189
|
-
# temporarily disabled
|
|
190
|
-
"RET503",
|
|
191
|
-
"TRY301"
|
|
192
|
-
]
|
|
193
|
-
|
|
194
|
-
[tool.ruff.lint.pydocstyle]
|
|
195
|
-
convention = "google"
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: kitchenowl-python
|
|
3
|
-
Version: 0.0.1
|
|
4
|
-
Summary: A python wrapper for the KitchenOwl API
|
|
5
|
-
Author: super-qua
|
|
6
|
-
Author-email: Tom Bursch <tom@kitchenowl.org>
|
|
7
|
-
License: MIT License
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2024 super-qua, Tom Bursch
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
|
|
29
|
-
Project-URL: Homepage, https://kitchenowl.org
|
|
30
|
-
Project-URL: Repository, https://github.com/tombursch/kitchenowl-python
|
|
31
|
-
Project-URL: Issues, https://github.com/TomBursch/kitchenowl/issues
|
|
32
|
-
Project-URL: Changelog, https://github.com/tombursch/kitchenowl-python/blob/main/CHANGELOG.md
|
|
33
|
-
Keywords: kitchenowl
|
|
34
|
-
Classifier: Development Status :: 3 - Alpha
|
|
35
|
-
Classifier: Programming Language :: Python
|
|
36
|
-
Requires-Python: >=3.8
|
|
37
|
-
Description-Content-Type: text/markdown
|
|
38
|
-
License-File: LICENSE
|
|
39
|
-
Requires-Dist: aiohttp==3.10.5
|
|
40
|
-
Provides-Extra: test
|
|
41
|
-
Requires-Dist: aioresponses==0.7.6; extra == "test"
|
|
42
|
-
Requires-Dist: pytest==8.2.2; extra == "test"
|
|
43
|
-
Requires-Dist: pytest-asyncio==0.23.7; extra == "test"
|
|
44
|
-
Requires-Dist: pytest-cov==6.0.0; extra == "test"
|
|
45
|
-
Requires-Dist: syrupy==4.6.1; extra == "test"
|
|
46
|
-
Provides-Extra: lint
|
|
47
|
-
Requires-Dist: ruff==0.6.1; extra == "lint"
|
|
48
|
-
|
|
49
|
-
# kitchenowl-python
|
|
50
|
-
A simple wrapper around the KitchenOwl API.
|
|
51
|
-
|
|
52
|
-
This is a small python package to be used as a wrapper for the KitchenOwl API in python.
|
|
53
|
-
|
|
54
|
-
Currently, there is only support for managing shopping list items.
|
|
55
|
-
|
|
56
|
-
## Installation
|
|
57
|
-
|
|
58
|
-
```shell
|
|
59
|
-
python -m venv .venv
|
|
60
|
-
source .venv/bin/activate
|
|
61
|
-
pip install -e .
|
|
62
|
-
```
|
|
63
|
-
Installs all required dependencies.
|
|
64
|
-
|
|
65
|
-
## Usage
|
|
66
|
-
|
|
67
|
-
```python
|
|
68
|
-
from aiohttp import ClientSession
|
|
69
|
-
from kitchenowl_python.kitchenowl import KitchenOwl
|
|
70
|
-
|
|
71
|
-
async with ClientSession() as session:
|
|
72
|
-
kitchenowl = KitchenOwl(session=session, url=url, token=token)
|
|
73
|
-
await kitchenowl.test_connection()
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Development
|
|
78
|
-
|
|
79
|
-
### Run tests
|
|
80
|
-
|
|
81
|
-
```shell
|
|
82
|
-
source .venv/bin/activate
|
|
83
|
-
pip install -e .\[test\]
|
|
84
|
-
pytest .
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
pyproject.toml
|
|
4
|
-
src/kitchenowl_python/__init__.py
|
|
5
|
-
src/kitchenowl_python/const.py
|
|
6
|
-
src/kitchenowl_python/exceptions.py
|
|
7
|
-
src/kitchenowl_python/kitchenowl.py
|
|
8
|
-
src/kitchenowl_python/types.py
|
|
9
|
-
src/kitchenowl_python.egg-info/PKG-INFO
|
|
10
|
-
src/kitchenowl_python.egg-info/SOURCES.txt
|
|
11
|
-
src/kitchenowl_python.egg-info/dependency_links.txt
|
|
12
|
-
src/kitchenowl_python.egg-info/requires.txt
|
|
13
|
-
src/kitchenowl_python.egg-info/top_level.txt
|
|
14
|
-
tests/test_kitchenowl.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
kitchenowl_python
|
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
"""Tests for the KitchenOwl API wrapper."""
|
|
2
|
-
|
|
3
|
-
import asyncio
|
|
4
|
-
from typing import Any, AsyncGenerator, Dict, Generator, Literal
|
|
5
|
-
|
|
6
|
-
import pytest
|
|
7
|
-
from aiohttp import ClientSession
|
|
8
|
-
from aiohttp.hdrs import METH_DELETE, METH_GET, METH_HEAD, METH_POST
|
|
9
|
-
from aioresponses import CallbackResult, aioresponses
|
|
10
|
-
|
|
11
|
-
from kitchenowl_python.exceptions import KitchenOwlAuthException, KitchenOwlRequestException
|
|
12
|
-
from kitchenowl_python.kitchenowl import KitchenOwl
|
|
13
|
-
from kitchenowl_python.types import (
|
|
14
|
-
KitchenOwlHouseholdsResponse,
|
|
15
|
-
KitchenOwlItem,
|
|
16
|
-
KitchenOwlShoppingList,
|
|
17
|
-
KitchenOwlShoppingListCategory,
|
|
18
|
-
KitchenOwlShoppingListItem,
|
|
19
|
-
KitchenOwlShoppingListItemsResponse,
|
|
20
|
-
KitchenOwlShoppingListsResponse,
|
|
21
|
-
KitchenOwlUser,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
from .data.defaults import (
|
|
25
|
-
DEFAULT_HEADERS,
|
|
26
|
-
DEFAULT_HOUSEHOLD_ID,
|
|
27
|
-
DEFAULT_HOUSEHOLDS_RESPONSE,
|
|
28
|
-
DEFAULT_ITEM,
|
|
29
|
-
DEFAULT_ITEM_ID_1,
|
|
30
|
-
DEFAULT_SHOPPINGLIST_ID_1,
|
|
31
|
-
DEFAULT_SHOPPINGLIST_ITEM_RESPONSE,
|
|
32
|
-
DEFAULT_SHOPPINGLIST_RESPONSE,
|
|
33
|
-
DEFAULT_SHOPPINGLIST_RESPONSE_2,
|
|
34
|
-
DEFAULT_USER_RESPONSE,
|
|
35
|
-
TEST_404_HOUSEHOLD_ID,
|
|
36
|
-
TEST_TOKEN,
|
|
37
|
-
TEST_URL,
|
|
38
|
-
UPDATED_ITEM_RESPONSE,
|
|
39
|
-
UPDATED_SHOPPINGLIST_ITEM_DESCRIPTION,
|
|
40
|
-
UPDATED_SHOPPINGLIST_ITEM_RESPONSE,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@pytest.fixture
|
|
45
|
-
def url():
|
|
46
|
-
"""The base URL for testing purposes."""
|
|
47
|
-
return TEST_URL
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@pytest.fixture
|
|
51
|
-
def token():
|
|
52
|
-
"""A long-lived access token for testing purposes."""
|
|
53
|
-
return TEST_TOKEN
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@pytest.fixture
|
|
57
|
-
async def kitchenowl_api(
|
|
58
|
-
url: Literal["https://kitchenowltest.local"], token: Literal["12345ABCD"]
|
|
59
|
-
) -> AsyncGenerator[KitchenOwl, None]:
|
|
60
|
-
"""The API client to use in the test interactions."""
|
|
61
|
-
async with ClientSession() as session:
|
|
62
|
-
client = KitchenOwl(session=session, url=url, token=token)
|
|
63
|
-
yield client
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
@pytest.fixture
|
|
67
|
-
def responses() -> Generator[aioresponses, None, None]:
|
|
68
|
-
"""Mock responses from aioresponses."""
|
|
69
|
-
with aioresponses() as mock_responses:
|
|
70
|
-
yield mock_responses
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@pytest.fixture
|
|
74
|
-
def default_shoppinglist() -> KitchenOwlShoppingList:
|
|
75
|
-
"""Default item used in update tests."""
|
|
76
|
-
return KitchenOwlShoppingList(DEFAULT_SHOPPINGLIST_RESPONSE)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
@pytest.fixture
|
|
80
|
-
def default_shoppinglist_2() -> KitchenOwlShoppingList:
|
|
81
|
-
"""Another item used in update tests."""
|
|
82
|
-
return KitchenOwlShoppingList(DEFAULT_SHOPPINGLIST_RESPONSE_2)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@pytest.fixture
|
|
86
|
-
def default_shoppinglists_response(
|
|
87
|
-
default_shoppinglist: KitchenOwlShoppingList, default_shoppinglist_2: KitchenOwlShoppingList
|
|
88
|
-
) -> KitchenOwlShoppingListItemsResponse:
|
|
89
|
-
"""Default items on the shopping list response."""
|
|
90
|
-
return KitchenOwlShoppingListsResponse([default_shoppinglist, default_shoppinglist_2])
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@pytest.fixture
|
|
94
|
-
def default_user_response() -> KitchenOwlUser:
|
|
95
|
-
"""Default items on the shopping list response."""
|
|
96
|
-
return KitchenOwlUser(DEFAULT_USER_RESPONSE)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
@pytest.fixture
|
|
100
|
-
def default_households_response() -> KitchenOwlHouseholdsResponse:
|
|
101
|
-
"""Default items on the shopping list response."""
|
|
102
|
-
return KitchenOwlHouseholdsResponse(DEFAULT_HOUSEHOLDS_RESPONSE)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
@pytest.fixture
|
|
106
|
-
def default_shoppinglist_item() -> KitchenOwlShoppingListItem:
|
|
107
|
-
"""Default item used in update tests."""
|
|
108
|
-
return KitchenOwlShoppingListItem(DEFAULT_SHOPPINGLIST_ITEM_RESPONSE)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
@pytest.fixture
|
|
112
|
-
def default_shoppinglist_item_2() -> KitchenOwlShoppingListItem:
|
|
113
|
-
"""Another item used in update tests."""
|
|
114
|
-
return KitchenOwlShoppingListItem(DEFAULT_SHOPPINGLIST_ITEM_RESPONSE)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
@pytest.fixture
|
|
118
|
-
def default_shoppinglist_items_response(
|
|
119
|
-
default_shoppinglist_item: KitchenOwlShoppingListItem,
|
|
120
|
-
default_shoppinglist_item_2: KitchenOwlShoppingListItem,
|
|
121
|
-
) -> KitchenOwlShoppingListItemsResponse:
|
|
122
|
-
"""Default items on the shopping list response."""
|
|
123
|
-
return KitchenOwlShoppingListItemsResponse(
|
|
124
|
-
[default_shoppinglist_item, default_shoppinglist_item_2]
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
@pytest.fixture
|
|
129
|
-
def default_suggested_item() -> KitchenOwlShoppingListItem:
|
|
130
|
-
"""Suggested item used in update tests."""
|
|
131
|
-
return KitchenOwlShoppingListItem(DEFAULT_SHOPPINGLIST_ITEM_RESPONSE)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
@pytest.fixture
|
|
135
|
-
def default_suggested_item_2() -> KitchenOwlShoppingListItem:
|
|
136
|
-
"""Another suggested item used in update tests."""
|
|
137
|
-
return KitchenOwlShoppingListItem(DEFAULT_SHOPPINGLIST_ITEM_RESPONSE)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
@pytest.fixture
|
|
141
|
-
def default_suggested_items_response(
|
|
142
|
-
default_suggested_item: KitchenOwlShoppingListItem,
|
|
143
|
-
default_suggested_item_2: KitchenOwlShoppingListItem,
|
|
144
|
-
) -> KitchenOwlShoppingListItemsResponse:
|
|
145
|
-
"""Suggested items for the shopping list."""
|
|
146
|
-
return KitchenOwlShoppingListItemsResponse([default_suggested_item, default_suggested_item_2])
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
@pytest.fixture
|
|
150
|
-
def default_item() -> KitchenOwlItem:
|
|
151
|
-
"""Default item used in update tests."""
|
|
152
|
-
return KitchenOwlItem(DEFAULT_ITEM)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
@pytest.fixture
|
|
156
|
-
def update_item_response() -> Dict[str, Any]:
|
|
157
|
-
"""Response to the updated item."""
|
|
158
|
-
return UPDATED_ITEM_RESPONSE
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
@pytest.fixture
|
|
162
|
-
def update_shoppinglist_item_response() -> Dict[str, Any]:
|
|
163
|
-
"""Response to the updated item."""
|
|
164
|
-
return UPDATED_SHOPPINGLIST_ITEM_RESPONSE
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
@pytest.mark.slow
|
|
168
|
-
async def test_timeout_exception(responses: aioresponses, kitchenowl_api: KitchenOwl):
|
|
169
|
-
"""Test request timeout."""
|
|
170
|
-
|
|
171
|
-
async def response_callback(_: str, **_kwargs: Any) -> CallbackResult:
|
|
172
|
-
"""Response handler for this test."""
|
|
173
|
-
await asyncio.sleep(4)
|
|
174
|
-
return CallbackResult(body="Awake!")
|
|
175
|
-
|
|
176
|
-
responses.head(
|
|
177
|
-
url=f"{TEST_URL}/api/user",
|
|
178
|
-
status=200,
|
|
179
|
-
callback=response_callback,
|
|
180
|
-
)
|
|
181
|
-
kitchenowl_api._request_timeout = 3 # noqa: SLF001
|
|
182
|
-
with pytest.raises(asyncio.TimeoutError):
|
|
183
|
-
await kitchenowl_api.test_connection()
|
|
184
|
-
|
|
185
|
-
responses.assert_called_once_with(
|
|
186
|
-
url=f"{TEST_URL}/api/user",
|
|
187
|
-
method=METH_HEAD,
|
|
188
|
-
headers=DEFAULT_HEADERS,
|
|
189
|
-
params=None,
|
|
190
|
-
json=None,
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
async def test_bad_response_exception(responses: aioresponses, kitchenowl_api: KitchenOwl):
|
|
195
|
-
"""Test server responding with non-json."""
|
|
196
|
-
responses.get(
|
|
197
|
-
url=f"{TEST_URL}/api/household/{DEFAULT_HOUSEHOLD_ID}/shoppinglist",
|
|
198
|
-
status=200,
|
|
199
|
-
headers={"Content-Type": "text/html"},
|
|
200
|
-
body="Hello from KitchenOwl",
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
with pytest.raises(KitchenOwlRequestException):
|
|
204
|
-
assert await kitchenowl_api.get_shoppinglists(DEFAULT_HOUSEHOLD_ID)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
async def test_not_found_exception(responses: aioresponses, kitchenowl_api: KitchenOwl):
|
|
208
|
-
"""Test a not found response from KitchenOwl."""
|
|
209
|
-
responses.get(
|
|
210
|
-
url=f"{TEST_URL}/api/household/{TEST_404_HOUSEHOLD_ID}/shoppinglist",
|
|
211
|
-
status=404,
|
|
212
|
-
body="Requested resource not found",
|
|
213
|
-
)
|
|
214
|
-
with pytest.raises(KitchenOwlRequestException):
|
|
215
|
-
await kitchenowl_api.get_shoppinglists(TEST_404_HOUSEHOLD_ID)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
async def test_auth_exception(responses: aioresponses, kitchenowl_api: KitchenOwl):
|
|
219
|
-
"""Test an authentication error."""
|
|
220
|
-
responses.get(
|
|
221
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/recent-items",
|
|
222
|
-
status=401,
|
|
223
|
-
headers={"Content-Type": "application/json"},
|
|
224
|
-
payload={"msg": "Unauthenticated"},
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
with pytest.raises(KitchenOwlAuthException):
|
|
228
|
-
await kitchenowl_api.get_shoppinglist_recent_items(DEFAULT_SHOPPINGLIST_ID_1)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
async def test_incorrect_token_exception(responses: aioresponses, kitchenowl_api: KitchenOwl):
|
|
232
|
-
"""Test a mock response if the token itself is incorrect."""
|
|
233
|
-
responses.get(
|
|
234
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/recent-items",
|
|
235
|
-
status=422,
|
|
236
|
-
headers={"Content-Type": "application/json"},
|
|
237
|
-
payload={"msg": "Not enough segments"},
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
with pytest.raises(KitchenOwlAuthException):
|
|
241
|
-
await kitchenowl_api.get_shoppinglist_recent_items(DEFAULT_SHOPPINGLIST_ID_1)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
async def test_connection_test(responses: aioresponses, kitchenowl_api: KitchenOwl):
|
|
245
|
-
"""Test the test_connection request."""
|
|
246
|
-
responses.head(
|
|
247
|
-
url=f"{TEST_URL}/api/user",
|
|
248
|
-
status=200,
|
|
249
|
-
headers={"Content-Type": "application/json"},
|
|
250
|
-
)
|
|
251
|
-
actual = await kitchenowl_api.test_connection()
|
|
252
|
-
assert actual is True
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
async def test_get_user_snapshot(
|
|
256
|
-
default_user_response: KitchenOwlUser,
|
|
257
|
-
responses: aioresponses,
|
|
258
|
-
kitchenowl_api: KitchenOwl,
|
|
259
|
-
snapshot,
|
|
260
|
-
):
|
|
261
|
-
"""Test get_user_info to match the snapshot."""
|
|
262
|
-
responses.get(
|
|
263
|
-
url=f"{TEST_URL}/api/user",
|
|
264
|
-
status=200,
|
|
265
|
-
headers={"Content-Type": "application/json"},
|
|
266
|
-
payload=default_user_response,
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
actual = await kitchenowl_api.get_user_info()
|
|
270
|
-
assert actual == snapshot
|
|
271
|
-
|
|
272
|
-
responses.assert_called_once_with(
|
|
273
|
-
url=f"{TEST_URL}/api/user",
|
|
274
|
-
method=METH_GET,
|
|
275
|
-
headers=DEFAULT_HEADERS,
|
|
276
|
-
params=None,
|
|
277
|
-
json=None,
|
|
278
|
-
)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
async def test_get_households_snapshot(
|
|
282
|
-
default_households_response: KitchenOwlHouseholdsResponse,
|
|
283
|
-
responses: aioresponses,
|
|
284
|
-
kitchenowl_api: KitchenOwl,
|
|
285
|
-
snapshot,
|
|
286
|
-
):
|
|
287
|
-
"""Test get_households to match the snapshot."""
|
|
288
|
-
responses.get(
|
|
289
|
-
url=f"{TEST_URL}/api/household",
|
|
290
|
-
status=200,
|
|
291
|
-
headers={"Content-Type": "application/json"},
|
|
292
|
-
payload=default_households_response,
|
|
293
|
-
)
|
|
294
|
-
|
|
295
|
-
actual = await kitchenowl_api.get_households()
|
|
296
|
-
assert actual == snapshot
|
|
297
|
-
|
|
298
|
-
responses.assert_called_once_with(
|
|
299
|
-
url=f"{TEST_URL}/api/household",
|
|
300
|
-
method=METH_GET,
|
|
301
|
-
headers=DEFAULT_HEADERS,
|
|
302
|
-
params=None,
|
|
303
|
-
json=None,
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
async def test_get_shoppinglists_snapshot(
|
|
308
|
-
default_shoppinglists_response: KitchenOwlShoppingListsResponse,
|
|
309
|
-
responses: aioresponses,
|
|
310
|
-
kitchenowl_api: KitchenOwl,
|
|
311
|
-
snapshot,
|
|
312
|
-
):
|
|
313
|
-
"""Test get_shoppinglists to match the snapshot."""
|
|
314
|
-
responses.get(
|
|
315
|
-
url=f"{TEST_URL}/api/household/{DEFAULT_HOUSEHOLD_ID}/shoppinglist",
|
|
316
|
-
status=200,
|
|
317
|
-
headers={"Content-Type": "application/json"},
|
|
318
|
-
payload=default_shoppinglists_response,
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
actual = await kitchenowl_api.get_shoppinglists(DEFAULT_HOUSEHOLD_ID)
|
|
322
|
-
assert actual == snapshot
|
|
323
|
-
|
|
324
|
-
responses.assert_called_once_with(
|
|
325
|
-
url=f"{TEST_URL}/api/household/{DEFAULT_HOUSEHOLD_ID}/shoppinglist",
|
|
326
|
-
method=METH_GET,
|
|
327
|
-
headers=DEFAULT_HEADERS,
|
|
328
|
-
params=None,
|
|
329
|
-
json=None,
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
async def test_get_shoppinglist_items_snapshot(
|
|
334
|
-
default_shoppinglist_items_response: KitchenOwlShoppingListItemsResponse,
|
|
335
|
-
responses: aioresponses,
|
|
336
|
-
kitchenowl_api: KitchenOwl,
|
|
337
|
-
snapshot,
|
|
338
|
-
):
|
|
339
|
-
"""Test get_shoppinglist_items to match the snapshot."""
|
|
340
|
-
responses.get(
|
|
341
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/items",
|
|
342
|
-
status=200,
|
|
343
|
-
headers={"Content-Type": "application/json"},
|
|
344
|
-
payload=default_shoppinglist_items_response,
|
|
345
|
-
)
|
|
346
|
-
|
|
347
|
-
actual = await kitchenowl_api.get_shoppinglist_items(DEFAULT_SHOPPINGLIST_ID_1)
|
|
348
|
-
assert actual == snapshot
|
|
349
|
-
|
|
350
|
-
responses.assert_called_once_with(
|
|
351
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/items",
|
|
352
|
-
method=METH_GET,
|
|
353
|
-
headers=DEFAULT_HEADERS,
|
|
354
|
-
params=None,
|
|
355
|
-
json=None,
|
|
356
|
-
)
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
async def test_get_shoppinglist_suggested_items_snapshot(
|
|
360
|
-
default_suggested_items_response: KitchenOwlShoppingListItemsResponse,
|
|
361
|
-
responses: aioresponses,
|
|
362
|
-
kitchenowl_api: KitchenOwl,
|
|
363
|
-
snapshot,
|
|
364
|
-
):
|
|
365
|
-
"""Test get_shoppinglist_suggested_items to match the snapshot."""
|
|
366
|
-
responses.get(
|
|
367
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/suggested-items",
|
|
368
|
-
status=200,
|
|
369
|
-
headers={"Content-Type": "application/json"},
|
|
370
|
-
payload=default_suggested_items_response,
|
|
371
|
-
)
|
|
372
|
-
|
|
373
|
-
actual = await kitchenowl_api.get_shoppinglist_suggested_items(DEFAULT_SHOPPINGLIST_ID_1)
|
|
374
|
-
assert actual == snapshot
|
|
375
|
-
|
|
376
|
-
responses.assert_called_once_with(
|
|
377
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/suggested-items",
|
|
378
|
-
method=METH_GET,
|
|
379
|
-
headers=DEFAULT_HEADERS,
|
|
380
|
-
params=None,
|
|
381
|
-
json=None,
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
async def test_add_shoppinglist_item(
|
|
386
|
-
default_shoppinglist_item: KitchenOwlShoppingListItem,
|
|
387
|
-
responses: aioresponses,
|
|
388
|
-
kitchenowl_api: KitchenOwl,
|
|
389
|
-
snapshot,
|
|
390
|
-
):
|
|
391
|
-
"""Test adding an item to a shoping list."""
|
|
392
|
-
|
|
393
|
-
responses.post(
|
|
394
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/add-item-by-name",
|
|
395
|
-
status=200,
|
|
396
|
-
payload=default_shoppinglist_item,
|
|
397
|
-
)
|
|
398
|
-
testitem = {
|
|
399
|
-
"name": f"item_{DEFAULT_ITEM_ID_1}",
|
|
400
|
-
"description": f"Description {DEFAULT_ITEM_ID_1}",
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
actual = await kitchenowl_api.add_shoppinglist_item(
|
|
404
|
-
DEFAULT_SHOPPINGLIST_ID_1, testitem["name"], testitem["description"]
|
|
405
|
-
)
|
|
406
|
-
|
|
407
|
-
assert actual == snapshot
|
|
408
|
-
|
|
409
|
-
responses.assert_called_once_with(
|
|
410
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/add-item-by-name",
|
|
411
|
-
method=METH_POST,
|
|
412
|
-
headers=DEFAULT_HEADERS,
|
|
413
|
-
params=None,
|
|
414
|
-
json={"name": testitem["name"], "description": testitem["description"]},
|
|
415
|
-
)
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
async def test_update_shoppinglist_item_description(
|
|
419
|
-
update_shoppinglist_item_response: Dict[str, Any],
|
|
420
|
-
default_shoppinglist_item: KitchenOwlShoppingListItem,
|
|
421
|
-
responses: aioresponses,
|
|
422
|
-
kitchenowl_api: KitchenOwl,
|
|
423
|
-
snapshot,
|
|
424
|
-
):
|
|
425
|
-
"""Test updating an item on a shoping list."""
|
|
426
|
-
|
|
427
|
-
responses.post(
|
|
428
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/item/{default_shoppinglist_item["id"]}",
|
|
429
|
-
status=200,
|
|
430
|
-
payload=update_shoppinglist_item_response,
|
|
431
|
-
)
|
|
432
|
-
default_shoppinglist_item["description"] = UPDATED_SHOPPINGLIST_ITEM_DESCRIPTION
|
|
433
|
-
actual = await kitchenowl_api.update_shoppinglist_item_description(
|
|
434
|
-
DEFAULT_SHOPPINGLIST_ID_1,
|
|
435
|
-
default_shoppinglist_item["id"],
|
|
436
|
-
default_shoppinglist_item["description"],
|
|
437
|
-
)
|
|
438
|
-
|
|
439
|
-
assert actual == snapshot
|
|
440
|
-
|
|
441
|
-
responses.assert_called_once_with(
|
|
442
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/item/{default_shoppinglist_item["id"]}",
|
|
443
|
-
method=METH_POST,
|
|
444
|
-
headers=DEFAULT_HEADERS,
|
|
445
|
-
params=None,
|
|
446
|
-
json={"description": default_shoppinglist_item["description"]},
|
|
447
|
-
)
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
async def test_remove_shoppinglist_item(responses: aioresponses, kitchenowl_api: KitchenOwl):
|
|
451
|
-
"""Test removing an item from a shoping list."""
|
|
452
|
-
|
|
453
|
-
responses.delete(
|
|
454
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/item",
|
|
455
|
-
status=200,
|
|
456
|
-
)
|
|
457
|
-
|
|
458
|
-
actual = await kitchenowl_api.remove_shoppinglist_item(
|
|
459
|
-
DEFAULT_SHOPPINGLIST_ID_1, DEFAULT_ITEM_ID_1
|
|
460
|
-
)
|
|
461
|
-
|
|
462
|
-
assert actual is True
|
|
463
|
-
|
|
464
|
-
responses.assert_called_once_with(
|
|
465
|
-
url=f"{TEST_URL}/api/shoppinglist/{DEFAULT_SHOPPINGLIST_ID_1}/item",
|
|
466
|
-
method=METH_DELETE,
|
|
467
|
-
headers=DEFAULT_HEADERS,
|
|
468
|
-
params=None,
|
|
469
|
-
json={"item_id": DEFAULT_ITEM_ID_1},
|
|
470
|
-
)
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
async def test_update_item_snapshot(
|
|
474
|
-
default_item: KitchenOwlItem,
|
|
475
|
-
update_item_response: Dict[str, Any],
|
|
476
|
-
responses: aioresponses,
|
|
477
|
-
kitchenowl_api: KitchenOwl,
|
|
478
|
-
snapshot,
|
|
479
|
-
):
|
|
480
|
-
"""Test updating an item."""
|
|
481
|
-
|
|
482
|
-
responses.post(
|
|
483
|
-
url=f"{TEST_URL}/api/item/{default_item["id"]}",
|
|
484
|
-
status=200,
|
|
485
|
-
payload=update_item_response,
|
|
486
|
-
)
|
|
487
|
-
# Update the category
|
|
488
|
-
default_item["category"] = KitchenOwlShoppingListCategory(id=2)
|
|
489
|
-
|
|
490
|
-
actual = await kitchenowl_api.update_item(default_item["id"], default_item)
|
|
491
|
-
|
|
492
|
-
assert actual == snapshot
|
|
493
|
-
responses.assert_called_once_with(
|
|
494
|
-
url=f"{TEST_URL}/api/item/{default_item["id"]}",
|
|
495
|
-
method=METH_POST,
|
|
496
|
-
headers=DEFAULT_HEADERS,
|
|
497
|
-
params=None,
|
|
498
|
-
json=default_item,
|
|
499
|
-
)
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
async def test_delete_item(
|
|
503
|
-
default_item: KitchenOwlItem,
|
|
504
|
-
responses: aioresponses,
|
|
505
|
-
kitchenowl_api: KitchenOwl,
|
|
506
|
-
):
|
|
507
|
-
"""Test deleting an item."""
|
|
508
|
-
|
|
509
|
-
responses.delete(
|
|
510
|
-
url=f"{TEST_URL}/api/item/{default_item["id"]}",
|
|
511
|
-
status=200,
|
|
512
|
-
payload={"msg": "Done"},
|
|
513
|
-
)
|
|
514
|
-
|
|
515
|
-
await kitchenowl_api.delete_item(default_item["id"])
|
|
516
|
-
|
|
517
|
-
responses.assert_called_once_with(
|
|
518
|
-
url=f"{TEST_URL}/api/item/{default_item["id"]}",
|
|
519
|
-
method=METH_DELETE,
|
|
520
|
-
headers=DEFAULT_HEADERS,
|
|
521
|
-
params=None,
|
|
522
|
-
json={},
|
|
523
|
-
)
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
async def test_delete_not_found_item(
|
|
527
|
-
default_item: KitchenOwlItem,
|
|
528
|
-
responses: aioresponses,
|
|
529
|
-
kitchenowl_api: KitchenOwl,
|
|
530
|
-
):
|
|
531
|
-
"""Test deleting an item that is not found."""
|
|
532
|
-
|
|
533
|
-
responses.delete(
|
|
534
|
-
url=f"{TEST_URL}/api/item/{default_item["id"]}",
|
|
535
|
-
status=404,
|
|
536
|
-
payload="Requested resource not found",
|
|
537
|
-
)
|
|
538
|
-
with pytest.raises(KitchenOwlRequestException):
|
|
539
|
-
await kitchenowl_api.delete_item(default_item["id"])
|
|
540
|
-
|
|
541
|
-
responses.assert_called_once_with(
|
|
542
|
-
url=f"{TEST_URL}/api/item/{default_item["id"]}",
|
|
543
|
-
method=METH_DELETE,
|
|
544
|
-
headers=DEFAULT_HEADERS,
|
|
545
|
-
params=None,
|
|
546
|
-
json={},
|
|
547
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|