From 9832e1ddc6f2fe505392db2c46276535ddaf9c02 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Tue, 11 Jan 2022 11:57:48 -0300 Subject: [PATCH] AutoHotKey 1st version. --- api/autohotkey/cli.py | 30 ++++++++++++++++++++++ api/autohotkey/features/autohotkey.feature | 12 +++++++++ api/autohotkey/features/steps/steps.py | 26 +++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/api/autohotkey/cli.py b/api/autohotkey/cli.py index c536525..0b27a4b 100644 --- a/api/autohotkey/cli.py +++ b/api/autohotkey/cli.py @@ -42,3 +42,33 @@ class AutoHotKey: else: return res.text + def test (self): + """ + ## AutoHotKey Test + Este método é utilizado para testar se o AutoHotKey está corretamente instalado na máquina do usuário, além de garantir que o serviço do mesmo também está instalado e funcionando corretamente. + + --- + #### Parâmetros: + --- + + --- + #### Retorna: + -> "AHK Svc Ok" caso tudo esteja funcionando corretamente. + """ + return self.__request_raw_post__ ("/ipc/ahk/test") + + def do (self, command: str): + """ + ## AutoHotKey Do + Realiza algum comando AutoHotKey passado como parâmetro. + + --- + #### Parâmetros: + - command: Comando AutoHotKey que se deseja executar + + --- + #### Retorna: + -> O retorno do comando, se houver. + """ + + return self.__request_raw_post__ ("/ipc/ahk/do", command) diff --git a/api/autohotkey/features/autohotkey.feature b/api/autohotkey/features/autohotkey.feature index e69de29..48094cd 100644 --- a/api/autohotkey/features/autohotkey.feature +++ b/api/autohotkey/features/autohotkey.feature @@ -0,0 +1,12 @@ +Feature: The AutoHotKey API client +# ======================== AutoHotKey Test ======================== + Scenario: Testing the AutoHotKey client + Given the AutoHotKey client + When the test method is called + Then the string "AHK Svc Ok" must be returned + +# ======================== AutoHotKey Test ======================== + Scenario: Using an AutoHotKey command through AutoHotKey client + Given the AutoHotKey client + When the do method is called + Then if there is a return in AHK, it must appear \ No newline at end of file diff --git a/api/autohotkey/features/steps/steps.py b/api/autohotkey/features/steps/steps.py index e69de29..4e4e398 100644 --- a/api/autohotkey/features/steps/steps.py +++ b/api/autohotkey/features/steps/steps.py @@ -0,0 +1,26 @@ +from behave import * + +from cli import AutoHotKey + +# ================================== AutoHotKey Test ================================== +@given(u'the AutoHotKey client') +def step_impl(context): + context.client = AutoHotKey () + +@when(u'the test method is called') +def step_impl(context): + context.test_return = context.client.test () + +@then(u'the string "AHK Svc Ok" must be returned') +def step_impl(context): + assert context.test_return == "AHK Svc Ok", "There is something wrong with te AHK or it's service." + + +# ================================== AutoHotKey Do ================================== +@when(u'the do method is called') +def step_impl(context): + context.do_return = context.client.do ('clipboard := "Riptide"') + +@then(u'if there is a return in AHK, it must appear') +def step_impl(context): + assert context.do_return == "", "Something went wrong with the command given." \ No newline at end of file