forked from ZennoLab/capmonstercloud-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmclient_test.py
More file actions
33 lines (24 loc) · 1.21 KB
/
Copy pathcmclient_test.py
File metadata and controls
33 lines (24 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import asyncio
import unittest
import os
from capmonstercloudclient.requests import RecaptchaV2Request
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.exceptions import UnknownRequestInstanceError
api_key = os.getenv('API_KEY')
class InstanceRequestTest(unittest.IsolatedAsyncioTestCase):
def testSuccessResponse(self):
options = ClientOptions(api_key=api_key)
client = CapMonsterClient(options=options)
request = RecaptchaV2Request(websiteUrl="https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
websiteKey="6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd")
# Success
response_1 = asyncio.run(client.solve_captcha(request))
self.assertTrue(isinstance(response_1, dict))
def testFailedInstanceRequest(self):
options = ClientOptions(api_key=api_key)
client = CapMonsterClient(options=options)
# Failed
with self.assertRaises(UnknownRequestInstanceError, msg='Unknown instance of request must call <UnknownRequestInstanceError>.'):
asyncio.run(client.solve_captcha('hmmm'))
if __name__ == '__main__':
unittest.main()