-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,67 @@ | ||
from pyflowlauncher import api | ||
|
||
|
||
def test_send_action(): | ||
assert api._send_action("Test", "Test") == {"method": "Flow.Launcher.Test", "parameters": ("Test",)} | ||
def check_output(func, method, parameters): | ||
req = func(*parameters) | ||
assert req["method"] == method | ||
assert req["parameters"] == parameters | ||
|
||
|
||
def test_get_namespace(): | ||
assert api._get_namespace("Test") == "Flow.Launcher.Test" | ||
|
||
|
||
def test_change_query(): | ||
assert api.change_query("Test", False) == {"method": "Flow.Launcher.ChangeQuery", "parameters": ("Test", False)} | ||
check_output(api.change_query, "Flow.Launcher.ChangeQuery", ["Test", False]) | ||
|
||
|
||
def test_shell_run(): | ||
assert api.shell_run("Test", "Test") == {"method": "Flow.Launcher.ShellRun", "parameters": ("Test", "Test")} | ||
check_output(api.shell_run, "Flow.Launcher.ShellRun", ["Test", "Test"]) | ||
|
||
|
||
def test_close_app(): | ||
assert api.close_app() == {"method": "Flow.Launcher.CloseApp", "parameters": ()} | ||
check_output(api.close_app, "Flow.Launcher.CloseApp", []) | ||
|
||
|
||
def test_hide_app(): | ||
assert api.hide_app() == {"method": "Flow.Launcher.HideApp", "parameters": ()} | ||
check_output(api.hide_app, "Flow.Launcher.HideApp", []) | ||
|
||
|
||
def test_show_app(): | ||
assert api.show_app() == {"method": "Flow.Launcher.ShowApp", "parameters": ()} | ||
check_output(api.show_app, "Flow.Launcher.ShowApp", []) | ||
|
||
|
||
def test_show_msg(): | ||
assert api.show_msg("Test", "Test", "Test") == {"method": "Flow.Launcher.ShowMsg", "parameters": ("Test", "Test", "Test")} | ||
check_output(api.show_msg, "Flow.Launcher.ShowMsg", ["Test", "Test", "Test"]) | ||
|
||
|
||
def test_open_setting_dialog(): | ||
assert api.open_setting_dialog() == {"method": "Flow.Launcher.OpenSettingDialog", "parameters": ()} | ||
check_output(api.open_setting_dialog, "Flow.Launcher.OpenSettingDialog", []) | ||
|
||
|
||
def test_start_loading_bar(): | ||
assert api.start_loading_bar() == {"method": "Flow.Launcher.StartLoadingBar", "parameters": ()} | ||
check_output(api.start_loading_bar, "Flow.Launcher.StartLoadingBar", []) | ||
|
||
|
||
def test_stop_loading_bar(): | ||
assert api.stop_loading_bar() == {"method": "Flow.Launcher.StopLoadingBar", "parameters": ()} | ||
check_output(api.stop_loading_bar, "Flow.Launcher.StopLoadingBar", []) | ||
|
||
|
||
def test_reload_plugins(): | ||
assert api.reload_plugins() == {"method": "Flow.Launcher.ReloadPlugins", "parameters": ()} | ||
check_output(api.reload_plugins, "Flow.Launcher.ReloadPlugins", []) | ||
|
||
|
||
def test_copy_to_clipboard(): | ||
assert api.copy_to_clipboard("Test", False, True) == {"method": "Flow.Launcher.CopyToClipboard", "parameters": ("Test", False, True)} | ||
check_output(api.copy_to_clipboard, "Flow.Launcher.CopyToClipboard", ["Test", False, True]) | ||
|
||
|
||
def test_open_directory(): | ||
assert api.open_directory("Test", "Test") == {"method": "Flow.Launcher.OpenDirectory", "parameters": ("Test", "Test")} | ||
check_output(api.open_directory, "Flow.Launcher.OpenDirectory", ["Test", "Test"]) | ||
|
||
|
||
def test_open_url(): | ||
assert api.open_url("Test", False) == {"method": "Flow.Launcher.OpenUrl", "parameters": ("Test", False)} | ||
check_output(api.open_url, "Flow.Launcher.OpenUrl", ["Test", False]) | ||
|
||
|
||
def test_open_uri(): | ||
assert api.open_uri("Test") == {"method": "Flow.Launcher.OpenAppUri", "parameters": ("Test",)} | ||
check_output(api.open_uri, "Flow.Launcher.OpenUri", ["Test"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from pyflowlauncher.jsonrpc import id_generation | ||
|
||
|
||
def test_increment_int(): | ||
id_gen = id_generation.incremental_int(1) | ||
assert next(id_gen) == 1 | ||
assert next(id_gen) == 2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from pyflowlauncher.jsonrpc import client | ||
|
||
|
||
def test_create_request(): | ||
assert client.create_request("Test", ["Test", False], id=1) == { | ||
"method": "Test", "parameters": ["Test", False], "id": 1, "jsonrpc": "2.0"} | ||
|
||
|
||
def test_request_from_string(): | ||
assert client.request_from_string( | ||
"Test", ["Test", False], id=1) == '{"jsonrpc": "2.0", "method": "Test", "parameters": ["Test", false], "id": 1}' | ||
|
||
|
||
def test_send_request(capsys): | ||
client.send_request(client.create_request("Test", ["Test", False], id=1)) | ||
captured = capsys.readouterr() | ||
assert captured.out == '{"jsonrpc": "2.0", "method": "Test", "parameters": ["Test", false], "id": 1}\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pyflowlauncher.jsonrpc import server | ||
|
||
|
||
def test_parse_request(): | ||
assert server.parse_request('{"jsonrpc": "2.0", "method": "Test", "params": ["Test", false], "id": 1}') == { | ||
"jsonrpc": "2.0", | ||
"method": "Test", | ||
"params": ["Test", False], | ||
"id": 1, | ||
} | ||
|
||
|
||
def test_create_response(): | ||
assert server.create_response("Test", 1) == { | ||
"jsonrpc": "2.0", | ||
"result": "Test", | ||
"id": 1, | ||
"SettingsChange": None, | ||
} | ||
|
||
|
||
def test_response(): | ||
assert server.response("Test", 1) == '{"jsonrpc": "2.0", "result": "Test", "id": 1, "SettingsChange": null}' |