def test_tide_can_start_and_returns_json(capsys): from tide import Tide tide_object = Tide() tide_object.start() capture = capsys.readouterr() tide_object.stop() assert len(capture) == 2
def test_tide_can_start_and_has_9_lines(self, capsys): from tide import Tide tide_object = Tide() tide_object.start() tide_object.stop() capture = capsys.readouterr() out_string = capture.out assert len(out_string.split("\n")) == 9
def test__run_command_with_match_on_hex(): try: tide_handler = Tide('test_mock') tide_handler.start() tide_handler.run_config_command("test_command") result = Config().get_variable("test_match_variable") tide_handler.stop() assert result == '0x00001234abcd' except Exception as ex: pytest.fail("error in filter tests: " + str(ex))
def test__run_command_with_match_on_array(): try: tide_handler = Tide() tide_handler.start() tide_handler.run_config_command("test_command") result = Config().get_variable("test_match_array") tide_handler.stop() assert '0x00001234abce' in result assert '0x000000009876' in result except Exception as ex: pytest.fail("error in filter tests: " + str(ex))
def test_tide_can_start_and_config_dictionary_has_internal_key(self, capsys): from tide import Tide tide_object = Tide() tide_object.start() tide_object.stop() capture = capsys.readouterr() out_string = capture.out out_strings = out_string.split("\n") json_string = out_strings[0] json_object = json.loads(json_string) assert "internal" in json_object["command"]["value"]["config_dictionary"].keys()
def test_tide_can_start_and_has_json_object_with_command_key(self, capsys): from tide import Tide tide_object = Tide() tide_object.start() tide_object.stop() capture = capsys.readouterr() out_string = capture.out out_strings = out_string.split("\n") json_string = out_strings[0] json_object = json.loads(json_string) assert "command" in json_object.keys()
def test_tide_can_start_and_has_json_object(self, capsys): from tide import Tide tide_object = Tide() tide_object.start() tide_object.stop() capture = capsys.readouterr() out_string = capture.out out_strings = out_string.split("\n") json_string = out_strings[0] json_object = json.loads(json_string) assert(isinstance(json_object, dict))
def test_tide_can_start_and_can_return_all_callbacks(self, capsys): full_count = 0 tide_object = Tide() tide_object.start() while True: capture = capsys.readouterr() capture_out = str(capture.out) if full_count == 4: break result = self.iterate_output_array(capture_out) full_count += len(result) assert full_count == 4
def try_run_tide(): try: import tide from tide import Tide tide_path = os.path.abspath(tide.__file__) tide_instance = Tide() tide_instance.start("stdio") except Exception as ex: running_file = sys.argv[0] pathname = os.path.dirname(running_file) running_path = os.path.abspath(pathname) error_file_path = os.path.abspath(__file__) + ".error.log" file_handle = open(error_file_path, "w+") file_handle.write("Running path: " + running_path) file_handle.write("\n\nGroups and Users:") file_handle.write("\n Effective group id: " + str(os.getegid())) file_handle.write("\n Effective user id: " + str(os.geteuid())) file_handle.write("\n Real group id: " + str(os.getgid())) file_handle.write("\n Supplemental group ids: " + str(os.getgroups())) file_handle.write("\n\nException handled running start-tide: \n\t" + str(ex)) file_handle.write("\n Traceback: \n\t" + traceback.format_exc()) file_handle.close()
def test_tide_can_start_and_can_return_all_callbacks_and_command_actions_are_correct( self, capsys): full_count = 0 results = [] tide_object = Tide() tide_object.start() while True: capture = capsys.readouterr() capture_out = str(capture.out) if full_count == 4: break result = self.iterate_output_array(capture_out) full_count += len(result) results.extend(result) assert results[0].get("command", {}).get("action", "") == "set_config_dictionary_item" assert results[1].get("command", {}).get("action", "") == "send_message_to_editor" assert results[2].get("command", {}).get("action", "") == "set_config_dictionary_item" assert results[3].get("command", {}).get("action", "") == "send_message_to_editor"
def test_tide_can_start(): tide_object = Tide() tide_object.start() tide_object.stop() assert type(tide_object) == type(Tide())