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

Commit

Permalink
Merge fdcb2b6 into c2aeb56
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRut committed Aug 23, 2021
2 parents c2aeb56 + fdcb2b6 commit 2d9deee
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
@@ -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 2d9deee

Please sign in to comment.