Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ferry_cli/helpers/ferry_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def parse_description(
name: str = "Endpoint", method: str = "", description: str = ""
) -> str:
description_lines = textwrap.wrap(description, width=60)
first_line = description_lines[0]
first_line = description_lines[0] if description_lines else ""
rest_lines = description_lines[1:]
endpoint_description = name.replace("/", "")

Expand Down
31 changes: 31 additions & 0 deletions tests/test_ferry_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest

from ferry_cli.helpers.ferry_parser import FerryParser


@pytest.mark.parametrize("description", ["", " ", "\n\t "])
def test_parse_description_blank(description):
"""A blank description should not abort endpoint generation."""
result = FerryParser.parse_description(
name="testEndpoint", method="GET", description=description
)
assert "testEndpoint" in result
assert "(GET)" in result


def test_parse_description_wraps_long_text():
description = "word " * 40
result = FerryParser.parse_description(
name="testEndpoint", method="GET", description=description
)
assert len(result.splitlines()) > 1


def test_set_arguments_with_blank_param_description():
"""Swagger parameters sometimes carry an empty description."""
parser = FerryParser.create(description="test")
parser.set_arguments(
[{"name": "unitname", "type": "string", "required": False, "description": ""}]
)
args = parser.parse_args(["--unitname", "testunit"])
assert args.unitname == "testunit"