diff --git a/CHANGELOG.md b/CHANGELOG.md index 136cbcb5..eed6429b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added flake8 check workflow on pull_request event [#321](https://github.com/scanapi/scanapi/pull/321) - Hide sensitive information in the URL Query Params [#304](https://github.com/scanapi/scanapi/pull/325) - Add anchor link for each request in the report to make it easily shareable. [#317](https://github.com/scanapi/scanapi/pull/317) +- Update black version on pre-commit configurations to avoid conflicts with flake8 [#346](https://github.com/scanapi/scanapi/pull/346) +- Added support to HTTP methods HEAD and OPTIONS [#350](https://github.com/scanapi/scanapi/pull/350) ### Changed - Updated poetry-publish version to v1.3 [#311](https://github.com/scanapi/scanapi/pull/311) diff --git a/scanapi/hide_utils.py b/scanapi/hide_utils.py index 2e32ce67..04a74b5a 100644 --- a/scanapi/hide_utils.py +++ b/scanapi/hide_utils.py @@ -23,7 +23,7 @@ def hide_sensitive_info(response): def _hide(http_msg, hide_settings): - """ Private method that finds all sensitive information attributes and calls _override_info + """Private method that finds all sensitive information attributes and calls _override_info to have sensitive data replaced """ for http_attr in hide_settings: diff --git a/scanapi/reporter.py b/scanapi/reporter.py index ca7da632..8fe7fb6e 100644 --- a/scanapi/reporter.py +++ b/scanapi/reporter.py @@ -17,8 +17,7 @@ def __init__(self, output_path=None, template=None): self.template = template def write(self, results): - """ Part of the Reporter instance that is responsible for writing scanapi-report.html. - """ + """Part of the Reporter instance that is responsible for writing scanapi-report.html.""" logger.info("Writing documentation") template_path = self.template if self.template else "report.html" @@ -35,7 +34,7 @@ def write(self, results): @staticmethod def _build_context(results): - """ Private method of Reporter returns dict containing keys datetime, + """Private method of Reporter returns dict containing keys datetime, project_name, results and session and their corresponding values. """ return { diff --git a/scanapi/scan.py b/scanapi/scan.py index c3ce1159..c84a4bc2 100644 --- a/scanapi/scan.py +++ b/scanapi/scan.py @@ -58,7 +58,7 @@ def scan(): def write_report(results): - """ Constructs a Reporter object and calls the write method of Reporter to push + """Constructs a Reporter object and calls the write method of Reporter to push the results to a file. """ reporter = Reporter(settings["output_path"], settings["template"]) diff --git a/scanapi/tree/request_node.py b/scanapi/tree/request_node.py index 23bff77b..3f1c0520 100644 --- a/scanapi/tree/request_node.py +++ b/scanapi/tree/request_node.py @@ -37,7 +37,15 @@ class RequestNode: DELAY_KEY, RETRY_KEY, ) - ALLOWED_HTTP_METHODS = ("GET", "POST", "PUT", "PATCH", "DELETE") + ALLOWED_HTTP_METHODS = ( + "GET", + "POST", + "PUT", + "PATCH", + "DELETE", + "HEAD", + "OPTIONS", + ) REQUIRED_KEYS = (NAME_KEY,) def __init__(self, spec, endpoint): diff --git a/scanapi/utils.py b/scanapi/utils.py index 1db4edda..b6aef0cd 100644 --- a/scanapi/utils.py +++ b/scanapi/utils.py @@ -7,7 +7,7 @@ def join_urls(first_url, second_url): - """ Function that returns one url if two aren't given else joins the two urls and + """Function that returns one url if two aren't given else joins the two urls and returns them. """ if not first_url: @@ -43,7 +43,7 @@ def _validate_required_keys(keys, required_keys, scope): def session_with_retry(retry_configuration): - """ Instantiate a requests session with the retry configuration if provided by + """Instantiate a requests session with the retry configuration if provided by instantiating an HTTPAdapter mounting it into the mounting it into the `requests.Session`. """ diff --git a/tests/unit/evaluators/test_spec_evaluator.py b/tests/unit/evaluators/test_spec_evaluator.py index a1ecf508..69337622 100644 --- a/tests/unit/evaluators/test_spec_evaluator.py +++ b/tests/unit/evaluators/test_spec_evaluator.py @@ -53,7 +53,7 @@ def test_return_evaluated_dict( ): mock_string_evaluate.side_effect = ["foo", "bar"] assert spec_evaluator.evaluate( - {"app_id": "foo", "token": "bar",} + {"app_id": "foo", "token": "bar"} ) == {"app_id": "foo", "token": "bar",} mock_string_evaluate.assert_has_calls( diff --git a/tests/unit/tree/test_request_node.py b/tests/unit/tree/test_request_node.py index 05dca0bb..8070cc16 100644 --- a/tests/unit/tree/test_request_node.py +++ b/tests/unit/tree/test_request_node.py @@ -50,16 +50,17 @@ def test_when_request_has_no_method(self): def test_when_method_is_invalid(self): request = RequestNode( - {"method": "xxx", "name": "foo", "path": "http:foo.com"}, + {"method": "XXX", "name": "foo", "path": "http:foo.com"}, endpoint=EndpointNode({"name": "foo", "requests": [{}]}), ) with pytest.raises(HTTPMethodNotAllowedError) as excinfo: request.http_method - assert ( - str(excinfo.value) == "HTTP method not supported: XXX. " - "Supported methods: ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')." + expected = ( + f"HTTP method not supported: {request.spec.get('method')}." + f" Supported methods: {request.ALLOWED_HTTP_METHODS}." ) + assert str(excinfo.value) == expected class TestName: def test_when_request_has_name(self):