Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_should_clean_and_save_preferences(self):
settings.save_click_preferences(
**{
"spec_path": "path/spec-path",
"reporter": None,
"output_path": "path/output-path",
"template": None,
"config_path": "path/config-path",
}
)
assert settings == {
"spec_path": "path/spec-path",
"output_path": "path/output-path",
"template": None,
"config_path": "path/config-path",
}
def test_should_pass_config_path_as_none(
self, mock_save_click_preferences, mock_save_config_file_preferences
):
preferences = {"foo": "bar"}
settings.save_preferences(**preferences)
mock_save_config_file_preferences.assert_called_with(None)
mock_save_click_preferences.assert_called_with(**preferences)
def define_settings(self):
settings["spec_path"] = "path/spec-path.yaml"
settings["output_path"] = "path/output-path.yaml"
settings["template"] = None
settings["config_path"] = "path/config-path.yaml"
def test_should_raise_exception(self):
with pytest.raises(FileNotFoundError) as excinfo:
config_path = "invalid/my_config_file.yaml"
settings.save_config_file_preferences(config_path)
assert (
str(excinfo.value)
== "[Errno 2] No such file or directory: 'invalid/my_config_file.yaml'"
)
def write_report(results):
reporter = Reporter(settings["output_path"], settings["template"])
reporter.write(results)
"""
Automated Testing and Documentation for your REST API.
SPEC_PATH argument is the API specification file path.
"""
session.start()
logging.basicConfig(level=log_level, format="%(message)s")
logger = logging.getLogger(__name__)
click_preferences = {
"spec_path": spec_path,
"output_path": output_path,
"config_path": config_path,
"template": template,
}
settings.save_preferences(**click_preferences)
scan()
def hide_sensitive_info(response):
report_settings = settings.get("report", {})
request = response.request
request_settings = report_settings.get("hide-request", {})
response_settings = report_settings.get("hide-response", {})
_hide(request, request_settings)
_hide(response, response_settings)
def _build_context(self, results):
return {
"now": datetime.datetime.now().replace(microsecond=0),
"project_name": settings.get("project-name", ""),
"results": results,
"session": session,
}