-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
ef6ffff
commit ee7fa5b
Showing
11 changed files
with
313 additions
and
32 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 |
---|---|---|
|
@@ -9,3 +9,5 @@ dist/ | |
MANIFEST | ||
*.egg-info | ||
_build | ||
|
||
tests/.config |
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
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
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
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,30 @@ | ||
import time | ||
|
||
from hookee.climanager import CliManager | ||
|
||
__author__ = "Alex Laird" | ||
__copyright__ = "Copyright 2020, Alex Laird" | ||
__version__ = "0.0.9" | ||
|
||
from tests.testcase import HookeeTestCase | ||
|
||
|
||
class ManagedTestCase(HookeeTestCase): | ||
port = 5000 | ||
cli_manager = None | ||
webhook_url = None | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.cli_manager = CliManager(cls.ctx) | ||
|
||
cls.cli_manager._init_server_and_tunnel() | ||
|
||
cls.webhook_url = "{}/webhook".format(cls.cli_manager.tunnel.public_url) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
if cls.cli_manager: | ||
cls.cli_manager.stop() | ||
|
||
time.sleep(2) |
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,109 @@ | ||
import os | ||
import shutil | ||
from unittest import mock | ||
|
||
from hookee.cli import hookee | ||
|
||
from tests.testcase import HookeeTestCase | ||
|
||
__author__ = "Alex Laird" | ||
__copyright__ = "Copyright 2020, Alex Laird" | ||
__version__ = "0.0.9" | ||
|
||
|
||
class TestCli(HookeeTestCase): | ||
def test_update_config(self): | ||
# WHEN | ||
result = self.runner.invoke(hookee, ["update-config", "port", "1000"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 0) | ||
self.assertIn("\"port\" has been updated", result.output) | ||
|
||
def test_update_invalid_config(self): | ||
# WHEN | ||
result = self.runner.invoke(hookee, ["update-config", "foo", "bar"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 2) | ||
self.assertIn("No such key", result.output) | ||
|
||
def test_available_plugins_config(self): | ||
# GIVEN | ||
custom_plugin_path = os.path.join(self.plugins_dir, "custom_plugin.py") | ||
shutil.copy( | ||
os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "hookee", "plugins", "request_body.py"), | ||
custom_plugin_path) | ||
|
||
# WHEN | ||
result = self.runner.invoke(hookee, ["available-plugins"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 0) | ||
self.assertIn( | ||
"['blueprint_default', 'custom_plugin', 'request_body', 'request_files', 'request_headers', " | ||
"'request_query_params', 'request_url_info', 'response_echo', 'response_info']", | ||
result.output) | ||
|
||
def test_enabled_plugins_config(self): | ||
# GIVEN | ||
self.config.remove("plugins", "request_files") | ||
self.config.remove("plugins", "request_query_params") | ||
|
||
# WHEN | ||
result = self.runner.invoke(hookee, ["enabled-plugins"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 0) | ||
self.assertIn( | ||
"['blueprint_default', 'request_body', 'request_headers', 'request_url_info', 'response_echo', " | ||
"'response_info']", | ||
result.output) | ||
|
||
def test_enable_plugin(self): | ||
# WHEN | ||
result = self.runner.invoke(hookee, ["enable-plugin", "request_body"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 0) | ||
self.assertIn("\"request_body\" has been enabled", result.output) | ||
|
||
def test_enable_plugin_invalid(self): | ||
# WHEN | ||
result = self.runner.invoke(hookee, ["enable-plugin", "fake_plugin"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 2) | ||
self.assertIn("\"fake_plugin\" could not be found", result.output) | ||
|
||
def test_disable_plugin(self): | ||
# WHEN | ||
result = self.runner.invoke(hookee, ["disable-plugin", "request_body"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 0) | ||
self.assertIn("\"request_body\" is disabled", result.output) | ||
|
||
def test_disable_required_plugin(self): | ||
# WHEN | ||
result = self.runner.invoke(hookee, ["disable-plugin", "blueprint_default"]) | ||
|
||
# THEN | ||
self.assertEqual(result.exit_code, 2) | ||
self.assertIn("can't disable", result.output) | ||
|
||
@mock.patch("hookee.climanager.CliManager.start") | ||
def test_start(self, mock_cli_start): | ||
# WHEN | ||
self.runner.invoke(hookee, ["start"]) | ||
|
||
# THEN | ||
mock_cli_start.assert_called_once() | ||
|
||
@mock.patch("hookee.climanager.CliManager.start") | ||
def test_no_command_calls_start(self, mock_cli_start): | ||
# WHEN | ||
self.runner.invoke(hookee) | ||
|
||
# THEN | ||
mock_cli_start.assert_called_once() |
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
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,9 +1,34 @@ | ||
import unittest | ||
from tests.testcase import HookeeTestCase | ||
|
||
__author__ = "Alex Laird" | ||
__copyright__ = "Copyright 2020, Alex Laird" | ||
__version__ = "0.0.8" | ||
__version__ = "0.0.9" | ||
|
||
|
||
class TestConfig(unittest.TestCase): | ||
pass | ||
class TestCli(HookeeTestCase): | ||
def test_config_set(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_config_append(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_config_remove(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN |
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,9 +1,88 @@ | ||
import unittest | ||
from tests.testcase import HookeeTestCase | ||
|
||
__author__ = "Alex Laird" | ||
__copyright__ = "Copyright 2020, Alex Laird" | ||
__version__ = "0.0.8" | ||
__version__ = "0.0.9" | ||
|
||
|
||
class TestPluginManager(unittest.TestCase): | ||
pass | ||
class TestPluginManager(HookeeTestCase): | ||
def test_validate_plugin(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_validate_plugin_not_conform_to_spec(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_validate_plugin_no_plugin_type(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_validate_plugin_no_run(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_validate_plugin_wrong_args(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_validate_plugin_no_blueprint(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_load_plugin_not_found(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_load_plugins(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN | ||
|
||
def test_load_plugins_missing_required_plugin(self): | ||
# TODO implement | ||
pass | ||
# GIVEN | ||
|
||
# WHEN | ||
|
||
# THEN |
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
Oops, something went wrong.