Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Don't format comments in clean_comment (#14)
Browse files Browse the repository at this point in the history
As noted in dask/helm-chart#92 (comment),
in some comments capitalization is important so frigate shouldn't change
it.
  • Loading branch information
TomAugspurger authored Aug 25, 2020
1 parent 874493d commit d138d18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions frigate/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ def get_comment(tree, key):
def clean_comment(comment):
"""Remove comment formatting.
Strip a comment down and turn it into a standalone human readable sentence.
Strip a comment.
Examples:
Strip down a comment
>>> clean_comment("# hello world")
"Hello world"
"hello world"
Args:
comment (str): Comment to clean
Expand All @@ -181,7 +181,7 @@ def clean_comment(comment):
str: Cleaned sentence
"""
return comment.strip("# ").capitalize()
return comment.strip("# ")


def traverse(tree, root=None):
Expand Down
21 changes: 12 additions & 9 deletions frigate/tests/test_frigate.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_get_comment(yaml):
from frigate.gen import get_comment

tree = yaml.load("hello: world # this is the comment")
assert get_comment(tree, "hello") == "This is the comment"
assert get_comment(tree, "hello") == "this is the comment"

tree = yaml.load(
"""
Expand All @@ -71,7 +71,7 @@ def test_get_comment(yaml):
# this is also not the comment
"""
)
assert get_comment(tree, "hello") == "This is the comment"
assert get_comment(tree, "hello") == "this is the comment"

tree = yaml.load(
"""
Expand All @@ -82,7 +82,7 @@ def test_get_comment(yaml):
# this is also not the comment
"""
)
assert get_comment(tree, "hello") == "This is the comment"
assert get_comment(tree, "hello") == "this is the comment"

tree = yaml.load(
"""
Expand All @@ -94,7 +94,7 @@ def test_get_comment(yaml):
# this is also not the comment
"""
)
assert get_comment(tree, "hello") == "This is the comment"
assert get_comment(tree, "hello") == "this is the comment"

tree = yaml.load(
"""
Expand All @@ -107,14 +107,17 @@ def test_get_comment(yaml):
)
assert get_comment(tree, "hello") == ""

tree = yaml.load("hello: world # Use a `LoadBalancer`.")
assert get_comment(tree, "hello") == "Use a `LoadBalancer`."


def test_clean_comment():
from frigate.gen import clean_comment

assert clean_comment("# hello world") == "Hello world"
assert clean_comment("hello world") == "Hello world"
assert clean_comment("## # ## ## hello world") == "Hello world"
assert clean_comment(" # hello world ") == "Hello world"
assert clean_comment("# hello world") == "hello world"
assert clean_comment("hello world") == "hello world"
assert clean_comment("## # ## ## hello world") == "hello world"
assert clean_comment(" # hello world ") == "hello world"


def test_traversal(simple_chart, rich_chart):
Expand All @@ -129,7 +132,7 @@ def test_traversal(simple_chart, rich_chart):

assert [
"replicaCount",
"Number of nginx pod replicas to create",
"number of nginx pod replicas to create",
"1",
] in rich_output

Expand Down

0 comments on commit d138d18

Please sign in to comment.