Skip to content

Commit ed35e1c

Browse files
authored
Updated the Installing.md docs and updated the sample_test.py.j2 file (#386)
* fixed sample_test and the docs * some clean up * updated docs * updated installing.md * Made changes to tree and the description for test --------- Co-authored-by: Shashank Venkat <shvenkat>
1 parent 6cf7240 commit ed35e1c

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

docs/installing.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,31 @@ $ tree -lla /home/ansible-dev/collections/ansible_collections/testns/testname
123123
│ └── runtime.yml
124124
├── plugins
125125
│ ├── action
126+
│ │ ├── sample_action.py
126127
│ │ └── __init__.py
127128
│ ├── cache
128129
│ │ └── __init__.py
130+
│ ├── lookup
131+
│ │ ├── sample_lookup.py
132+
│ │ └── __init__.py
129133
│ ├── filter
130-
│ │ ├── hello_world.py
134+
│ │ ├── sample_filter.py
131135
│ │ └── __init__.py
132136
│ ├── inventory
133137
│ │ └── __init__.py
134138
│ ├── modules
139+
│ │ ├── sample_module.py
140+
│ │ ├── sample_action.py
135141
│ │ └── __init__.py
136142
│ ├── module_utils
137143
│ │ └── __init__.py
138144
│ ├── plugin_utils
139145
│ │ └── __init__.py
140146
│ ├── sub_plugins
141147
│ │ └── __init__.py
142-
│ └── test
143-
│ └── __init__.py
148+
│ ├── test
149+
│ │ ├── sample_test.py
150+
│ │ └── __init__.py
144151
├── .pre-commit-config.yaml
145152
├── .prettierignore
146153
├── pyproject.toml
@@ -381,6 +388,7 @@ $ ansible-creator add plugin <plugin-type> <plugin-name> <collection-path>
381388
| filter | Add a filter plugin to an existing Ansible Collection. |
382389
| lookup | Add a lookup plugin to an existing Ansible Collection. |
383390
| module | Add a generic module to an existing Ansible Collection. |
391+
| test | Add a test plugin to an existing Ansible Collection. |
384392

385393
#### Example of adding a plugin
386394

src/ansible_creator/resources/collection_project/plugins/test/sample_test.py.j2

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,23 @@ DOCUMENTATION = """
2525
version_added: "1.0.0"
2626
short_description: {{ description }}
2727
description:
28-
- This is a demo test plugin designed to return Hello message.
28+
- This is a demo test plugin designed to return a bool.
2929
options:
3030
name:
31-
description: Value specified here is appended to the Hello message.
32-
type: str
31+
type: bool
3332
"""
3433

3534
EXAMPLES = """
3635
# {{ test_name }} test example
3736
{% raw %}
38-
- name: Display a hello message
37+
- name: Display a bool
3938
ansible.builtin.debug:
4039
msg: "{{ 50 {%- endraw %} | {{ test_name }} }}"
4140
"""
4241

4342

44-
def _hello_world(val: int) -> bool:
45-
"""Returns Hello message.
43+
def _sample_test(val: int) -> bool:
44+
"""Returns a bool.
4645

4746
Args:
4847
val: The value to test.
@@ -62,4 +61,4 @@ class TestModule:
6261
Returns:
6362
dict: The test plugin functions.
6463
"""
65-
return {"{{ test_name }}": _hello_world}
64+
return {"{{ test_name }}": _sample_test}

tests/fixtures/collection/testorg/testcol/plugins/test/sample_test.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@
2020
version_added: "1.0.0"
2121
short_description: A custom test plugin for Ansible.
2222
description:
23-
- This is a demo test plugin designed to return Hello message.
23+
- This is a demo test plugin designed to return a bool.
2424
options:
2525
name:
26-
description: Value specified here is appended to the Hello message.
27-
type: str
26+
type: bool
2827
"""
2928

3029
EXAMPLES = """
3130
# sample_test test example
3231
33-
- name: Display a hello message
32+
- name: Display a bool
3433
ansible.builtin.debug:
3534
msg: "{{ 50 | sample_test }}"
3635
"""
3736

3837

39-
def _hello_world(val: int) -> bool:
40-
"""Returns Hello message.
38+
def _sample_test(val: int) -> bool:
39+
"""Returns a bool.
4140
4241
Args:
4342
val: The value to test.
@@ -57,4 +56,4 @@ def tests(self) -> dict[str, Callable[[int], bool]]:
5756
Returns:
5857
dict: The test plugin functions.
5958
"""
60-
return {"sample_test": _hello_world}
59+
return {"sample_test": _sample_test}

tests/units/test_init.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ def mock_unique_name_in_devfile(init: Init) -> str:
134134
# check stdout
135135
assert re.search(r"Note: collection project created", result) is not None
136136

137-
# Fix the directory structure to match the expected fixture
138-
# Rename 'integration_' to 'integration_hello_world'
139-
generated_molecule_dir = tmp_path / "testorg" / "testcol" / "extensions" / "molecule"
140-
if (generated_molecule_dir / "integration_").exists():
141-
(generated_molecule_dir / "integration_").rename(
142-
generated_molecule_dir / "integration_hello_world"
143-
)
144-
145137
# recursively assert files created
146138
cmp = dircmp(str(tmp_path), str(FIXTURES_DIR / "collection"), ignore=[".DS_Store"])
147139
diff = has_differences(dcmp=cmp, errors=[])

0 commit comments

Comments
 (0)