Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the ability to send data-parameters to requests #1

Merged
merged 2 commits into from
Nov 24, 2017

Conversation

Nataliska
Copy link

No description provided.

jj/rule.py Outdated
@@ -3,11 +3,12 @@

class Rule:

def __init__(self, method, route, params, headers):
def __init__(self, method, route, params, headers, data):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data - слишком много охватывает, лучше ограничить, т.к. для текущей задачи нужен только json

jj/rule.py Outdated
def match(self, request):
return self.__match_method(request.method) and \
self.__match_route(request.path) and \
self.__match_params(request.args) and \
self.__match_headers(request.headers)
self.__match_headers(request.headers) and \
self.__match_data(eval(request.data))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval - лучше не использовать

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

payload = request.get_data(as_text=True)
if request.content_type == 'application/json':
    json_payload = json.loads(payload)

Только нужно вынести в отдельный метод

updated data to json in mock.py
@tsv1 tsv1 merged commit c09f74e into jj-mock:master Nov 24, 2017
@Nataliska Nataliska deleted the add-data-params-to-requests branch November 24, 2017 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants