Skip to content

Commit

Permalink
chore: fix tests for web provider - recheck with #80
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Jun 18, 2022
1 parent 8c3b687 commit 77b422c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
16 changes: 13 additions & 3 deletions tackle/providers/web/hooks/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ class RequestsPostHook(BaseHook):
description="Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.",
render_by_default=True
)
input_json: dict = None
# TODO: Fix alias so input_json -> json
# https://github.com/robcxyz/tackle-box/issues/80
input_json: dict = Field(
False,
description="Whether to exit on non-200 response.",
render_by_default=True
)
no_exit: bool = Field(False, description="Whether to exit on non-200 response.")
# fmt: on

Expand Down Expand Up @@ -113,11 +119,13 @@ class RequestsPutHook(BaseHook):
data: Any = Field(
None,
description="Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.",
render_by_default=True
)
# TODO: Fix alias so input_json -> json
# https://github.com/robcxyz/tackle-box/issues/80
input_json: dict = Field(
None,
description="Json data to send in the body of the Request.",
render_by_default=True
)
no_exit: bool = Field(False, description="Whether to exit on non-200 response.")
# fmt: off
Expand Down Expand Up @@ -148,11 +156,13 @@ class RequestsPatchHook(BaseHook):
data: Any = Field(
None,
description="Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.",
render_by_default=True
)
# TODO: Fix alias so input_json -> json
# https://github.com/robcxyz/tackle-box/issues/80
input_json: dict = Field(
None,
description="Json data to send in the body of the Request.",
render_by_default=True,
)
no_exit: bool = Field(False, description="Whether to exit on non-200 response.")
# fmt: off
Expand Down
4 changes: 2 additions & 2 deletions tackle/providers/web/tests/delete.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
compact->: http_delete https://reqres.in/api/users/2
compact->: http_delete https://httpbin.org/delete
expanded:
->: http_delete
url: https://reqres.in/api/users/2
url: https://httpbin.org/delete
4 changes: 2 additions & 2 deletions tackle/providers/web/tests/get.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
compact->: http_get https://jsonplaceholder.typicode.com/todos/1
compact->: http_get https://httpbin.org/get
expanded:
->: http_get
url: https://jsonplaceholder.typicode.com/todos/1
url: https://httpbin.org/get
4 changes: 2 additions & 2 deletions tackle/providers/web/tests/patch.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
input_json:
stuff: things

compact->: http_patch https://reqres.in/api/users/2 input_json
compact->: http_patch https://httpbin.org/patch --input_json input_json

expanded:
->: http_patch
url: https://reqres.in/api/users/2
url: https://httpbin.org/patch
input_json:
stuff: things
4 changes: 2 additions & 2 deletions tackle/providers/web/tests/post.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
input_json:
stuff: things

compact->: http_post https://reqres.in/api/users input_json
compact->: http_post https://httpbin.org/post --input_json input_json

expanded:
->: http_post
url: https://reqres.in/api/users
url: https://httpbin.org/post
input_json:
stuff: things
6 changes: 3 additions & 3 deletions tackle/providers/web/tests/put.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
input_json:
stuff: things

compact->: http_put https://reqres.in/api/users input_json
compact_2->: http_put https://reqres.in/api/users {'stuff':'things'}
compact->: http_put https://httpbin.org/put input_json
compact_2->: http_put https://httpbin.org/put {'stuff':'things'}

expanded:
->: http_put
url: https://reqres.in/api/users/2
url: https://httpbin.org/put
input_json:
stuff: things
12 changes: 6 additions & 6 deletions tackle/providers/web/tests/test_requests_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

def test_provider_requests_get(change_dir):
output = tackle('get.yaml', no_input=True)
assert output['expanded']['userId'] == 1
assert output['expanded'] == output['compact']
assert output['compact']['url'] == output['expanded']['url']


def test_provider_requests_post(change_dir):
output = tackle('post.yaml', no_input=True)
assert output['expanded']['stuff'] == "things"
assert output['expanded']['json']['stuff'] == "things"
assert output['expanded']['json'] == output['compact']['json']


def test_provider_requests_put(change_dir):
output = tackle('put.yaml', no_input=True)
assert output['expanded']['stuff'] == "things"
assert output['expanded']['json']['stuff'] == "things"


def test_provider_requests_patch(change_dir):
output = tackle('patch.yaml', no_input=True)
assert output['expanded']['stuff'] == "things"
assert output['expanded']['json']['stuff'] == "things"


def test_provider_requests_delete(change_dir):
output = tackle('delete.yaml', no_input=True)
assert output['expanded'] == 204
assert output['expanded'] == 200

0 comments on commit 77b422c

Please sign in to comment.