Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/update-for-grocy-3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRut committed Aug 23, 2021
2 parents 9a0c845 + 9844118 commit 1e548c1
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 4 deletions.
4 changes: 1 addition & 3 deletions requirements-dev.txt
@@ -1,6 +1,4 @@
responses~=0.13.3
tzlocal~=2.1
iso8601~=0.1.16
responses~=0.13.4
pre-commit
isort
pytest
Expand Down
8 changes: 7 additions & 1 deletion setup.py
Expand Up @@ -14,7 +14,13 @@
url="https://github.com/sebrut/pygrocy",
license="MIT",
packages=setuptools.find_packages(),
install_requires=["requests", "iso8601", "pytz", "tzlocal", "deprecation"],
install_requires=[
"requests",
"iso8601~=0.1.16",
"pytz~=2021.1",
"tzlocal>=2.1,<3.0",
"deprecation~=2.1.0",
],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down
@@ -0,0 +1,44 @@
interactions:
- request:
body: '{"tracked_time": "2021-08-23T08:17:14.341685+00:00"}'
headers:
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '52'
Content-Type:
- application/json
User-Agent:
- python-requests/2.25.1
accept:
- application/json
method: POST
uri: https://localhost/api/chores/1000/execute
response:
body:
string: '{"error_message":"Chore does not exist"}'
headers:
Access-Control-Allow-Headers:
- '*'
Access-Control-Allow-Methods:
- GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Mon, 23 Aug 2021 08:17:14 GMT
Server:
- nginx/1.20.1
Transfer-Encoding:
- chunked
X-Powered-By:
- PHP/8.0.9
status:
code: 400
message: Bad Request
version: 1
@@ -0,0 +1,49 @@
interactions:
- request:
body: '{"tracked_time": "2021-08-23T08:17:14.341685+00:00"}'
headers:
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '52'
Content-Type:
- application/json
User-Agent:
- python-requests/2.25.1
accept:
- application/json
method: POST
uri: https://localhost/api/chores/1/execute
response:
body:
string: !!binary |
H4sIAAAAAAAEA3WNywrCMBBFf0XuOoUkCpb5mSEmAxbbRKYJUsR/lz5curtncc59Y0gg5w3ivajw
RgZVQ3xI4jpMAoK33nW27/z5ZHtyV3IXGKSShW8Lt1n0J2p5cVQJ9ZDnGqbn30LLawNkDfa5HR5O
buP4+QLriBPloAAAAA==
headers:
Access-Control-Allow-Headers:
- '*'
Access-Control-Allow-Methods:
- GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
Date:
- Mon, 23 Aug 2021 08:17:14 GMT
Server:
- nginx/1.20.1
Transfer-Encoding:
- chunked
X-Powered-By:
- PHP/8.0.9
status:
code: 200
message: OK
version: 1
@@ -0,0 +1,49 @@
interactions:
- request:
body: '{"tracked_time": "2020-12-01T15:00:00+00:00", "done_by": 1}'
headers:
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '59'
Content-Type:
- application/json
User-Agent:
- python-requests/2.25.1
accept:
- application/json
method: POST
uri: https://localhost/api/chores/1/execute
response:
body:
string: !!binary |
H4sIAAAAAAAEA3WNywrCMBBFf0XuOoU0QSzzM0NMBiy2iUwTRMR/lz5curtncc59Y0yg3hvEW1Hh
jQyqhniXxHWcBQRnXd/ZoXP+ZAdyns4XGKSSha8vbovoT9Ty5KgS6iEvNcyPv4WW1wbIGuxzOzyc
3Kbp8wVSZJlQoAAAAA==
headers:
Access-Control-Allow-Headers:
- '*'
Access-Control-Allow-Methods:
- GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
Date:
- Mon, 23 Aug 2021 08:23:57 GMT
Server:
- nginx/1.20.1
Transfer-Encoding:
- chunked
X-Powered-By:
- PHP/8.0.9
status:
code: 200
message: OK
version: 1
19 changes: 19 additions & 0 deletions test/test_chores.py
Expand Up @@ -4,6 +4,7 @@

from pygrocy.data_models.chore import AssignmentType, Chore, PeriodType
from pygrocy.data_models.user import User
from pygrocy.errors.grocy_error import GrocyError


class TestChores:
Expand Down Expand Up @@ -42,3 +43,21 @@ def test_get_chore_details(self, grocy):
assert chore_details.next_execution_assigned_user.id == 2
assert chore_details.next_execution_assigned_to_user_id == 2
assert chore_details.userfields is None

@pytest.mark.vcr
def test_execute_chore_valid(self, grocy):
result = grocy.execute_chore(1)
assert not isinstance(result, GrocyError)

@pytest.mark.vcr
def test_execute_chore_valid_with_data(self, grocy):
result = grocy.execute_chore(1, done_by=1, tracked_time=datetime.now())
assert not isinstance(result, GrocyError)

@pytest.mark.vcr
def test_execute_chore_invalid(self, grocy):
with pytest.raises(GrocyError) as exc_info:
grocy.execute_chore(1000)

error = exc_info.value
assert error.status_code == 400

0 comments on commit 1e548c1

Please sign in to comment.