Skip to content

Commit

Permalink
add unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
goFrendiAsgard committed Dec 9, 2023
1 parent 82252ec commit 6e4eb13
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/helper/test_fetch_external_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def test_fetch_external_env():
assert external_env.get('HOST_B1') == ''
assert external_env.get('HOST_B2') == ''
assert external_env.get('HOST_B3') == 'localhost'
assert external_env.get('URL_B') == ''
assert external_env.get('URL_B') == ''
47 changes: 47 additions & 0 deletions test/helper/test_get_markdown_from_docstring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from zrb.helper.docstring import get_markdown_from_docstring


class SampleClass:
"""
This is a sample class for testing.
Attributes:
attribute1 (int): An example attribute.
"""

def method1(self, param1: str) -> bool:
"""
An example method.
Args:
param1 (str): A sample parameter.
Returns:
bool: The return value.
Examples:
>>> sc = SampleClass()
>>> sc.method1("test")
"""
return True


def test_get_markdown_from_docstring():
expected_output = (
"## `SampleClass`\n\n"
"This is a sample class for testing.\n\n"
"__Attributes:__\n\n"
"- `attribute1` (`int`): An example attribute.\n"
"\n### `SampleClass.method1`\n\n"
"An example method.\n\n"
"__Arguments:__\n\n"
"- `param1` (`str`): A sample parameter.\n\n"
"__Returns:__\n\n"
"`bool`: The return value.\n\n"
"__Examples:__\n\n"
"```python\n"
"sc = SampleClass()\n"
"sc.method1(\"test\")\n"
"```\n\n"
)
assert get_markdown_from_docstring(SampleClass) == expected_output
2 changes: 1 addition & 1 deletion zrb_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def make_docs(*args: Any, **kwargs: Any):
'set -e',
f'cd {CURRENT_DIR}',
'echo "🤖 Perform test"',
'pytest --ignore-glob="**/template/**/test" --ignore-glob="**/generator/**/app" --ignore=playground --cov=zrb --cov-config=".coveragerc" --cov-report=html --cov-report=term --cov-report=term-missing {{input.test}}' # noqa
'pytest -vv --ignore-glob="**/template/**/test" --ignore-glob="**/generator/**/app" --ignore=playground --cov=zrb --cov-config=".coveragerc" --cov-report=html --cov-report=term --cov-report=term-missing {{input.test}}' # noqa
],
retry=0,
checking_interval=1
Expand Down

0 comments on commit 6e4eb13

Please sign in to comment.