Skip to content

Commit

Permalink
Update tests and gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDrang committed Dec 20, 2019
1 parent 901ee7c commit f43b0cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ __pycache__/
*.xml

dist/

env/
23 changes: 21 additions & 2 deletions tests/test_Control.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def test_params(self):
assert default_complaint_params == complaint_params[0]
assert default_queue_status_params == queue_status_params[0]

"""
Request payload test MOCK
"""

def test_balance_payload(self):
control = AntiCaptchaControl.AntiCaptchaControl(anticaptcha_key=self.anticaptcha_key_true)
# check response type
Expand Down Expand Up @@ -133,8 +137,7 @@ def test_complaint_re_payload(self):
# check response type
assert isinstance(control, AntiCaptchaControl.AntiCaptchaControl)
task_id = 123456
print(config.incorrect_recaptcha_url)
print(AntiCaptchaControl.complaint_types[1])

with requests_mock.Mocker() as req_mock:
req_mock.post(config.incorrect_recaptcha_url, json=self.ERROR_RESPONSE_JSON)
control.complaint_on_result(
Expand All @@ -152,6 +155,22 @@ def test_complaint_re_payload(self):
assert request_payload["clientKey"] == self.anticaptcha_key_true
assert request_payload["taskId"] == task_id

def test_queue_payload(self):
queue_id = random.choice(AntiCaptchaControl.queue_ids)
with requests_mock.Mocker() as req_mock:
req_mock.post(config.get_queue_status_url, json=self.ERROR_RESPONSE_JSON)
AntiCaptchaControl.AntiCaptchaControl.get_queue_status(queue_id)

history = req_mock.request_history

assert len(history) == 1

request_payload = history[0].json()

# check all dict keys
assert ["queueId",] == list(request_payload.keys())
assert request_payload["queueId"] == queue_id

"""
Response checking
"""
Expand Down

0 comments on commit f43b0cc

Please sign in to comment.