AutoIt client 1st version.

anticaptcha
Pedro de Oliveira Guedes 2022-01-11 10:36:15 -03:00
parent 50ae4fdb7f
commit b48f2b7e2a
2 changed files with 65 additions and 4 deletions

View File

@ -13,10 +13,10 @@ class AutoIt:
"""
ep: str = ""
def __init__(self):
def __init__ (self):
self.ep = "https://localhost:8443"
def __request_raw_post__(self, path: str, data: str):
def __request_raw_post__ (self, path: str, data: str = ""):
"""
## HTTP RAW POST
@ -39,3 +39,35 @@ class AutoIt:
return json.loads(res.text)
else:
return res.text
def test (self):
"""
## AutoIt test
Este método é utilizado para testar se o AutoIt está corretamente instalado na máquina do usuário, além de garantir que o serviço também está instalado e funcionando corretamente.
---
#### Parâmetros:
---
---
#### Retorna:
-> "Autoit Svc Ok" caso tudo esteja funcionando corretamente.
"""
return self.__request_raw_post__ ("/ipc/autoit/test")
def do (self, command: str):
"""
## AutoIt Do
Realiza algum comando Autoit passado como parâmetro.
---
#### Parâmetros:
- command: Comando autoit que se deseja executar
---
#### Retorna:
-> O retorno do comando, se houver.
"""
return self.__request_raw_post__ ("/ipc/autoit/do", command)

View File

@ -1,3 +1,32 @@
from typing import Text
from behave import *
from cli import AutoIt
# ================================== AutoIt Test ==================================
@given(u'the AutoIt client')
def step_impl(context):
context.client = AutoIt()
@when(u'the test method is called')
def step_impl(context):
context.test_return = context.client.test()
@then(u'the string "Autoit Svc Ok" must be returned')
def step_impl(context):
assert context.test_return == "Autoit Svc Ok", "There is something wrong with your AutoIt."
# ================================== AutoIt Do ==================================
@when(u'the do method is called with "ClipPut ( "test" )"')
def step_impl(context):
context.do_return = context.client.do('ClipPut ( "test" )')
@then(u'the string "test" must me recorded on ClipBoard')
def step_impl(context):
print (f"""
-----------------
{context.client.do ( "ClipGet ( )" )}
-----------------
""")
assert context.client.do( "ClipGet ()" ) == "", "Something went wrong with the ClipPut method."