-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix catalog collections script to display all available modules in a …
…collection (#1738) * Fix catalog collections script * Parse examples, returndocs, metadata info * Add test for get_doc_withast function * Pre-commit and other logic fixes * Improve code coverage * Add test * Fix test_catalog_collections.py * More fixes in test_catalog_collections.py * Add test_worker_with_mocked_get_docstring * More fixes in test
- Loading branch information
1 parent
cba44f8
commit d494578
Showing
6 changed files
with
140 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,5 +116,6 @@ usefixtures | |
userbase | ||
viewcode | ||
volmount | ||
withast | ||
workdir | ||
xmss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""An ansible test module.""" | ||
|
||
DOCUMENTATION = r""" | ||
--- | ||
module: vcenter_mod | ||
short_description: Gather info vCenter extensions | ||
description: | ||
- This module can be used to gather information about vCenter extension. | ||
author: | ||
- test | ||
extends_documentation_fragment: | ||
- community.vmware.vmware.documentation | ||
""" | ||
|
||
EXAMPLES = "Example usage here." | ||
RETURN = "This function returns a value." | ||
METADATA = "Author: John Doe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"""Unit tests for catalog collections.""" | ||
|
||
import multiprocessing | ||
|
||
from pathlib import Path | ||
from typing import Any | ||
|
||
from ansible_navigator.data.catalog_collections import worker | ||
|
||
|
||
def test_worker_with_failed_get_docstring() -> None: | ||
"""Test worker function when get_docstring fails and get_doc_withast method is used to parse the content.""" | ||
# Create the queues | ||
pending_queue: multiprocessing.Queue[Any] = multiprocessing.Queue() | ||
completed_queue: multiprocessing.Queue[Any] = multiprocessing.Queue() | ||
|
||
plugin_path = Path("tests/fixtures/common/module_1.py") | ||
collection_name = "microsoft.ad" | ||
checksum = "12345" | ||
|
||
# Add an entry to the pending queue | ||
entry = collection_name, checksum, plugin_path | ||
pending_queue.put(entry) | ||
|
||
# Add a None entry to signal the end of processing | ||
pending_queue.put(None) | ||
|
||
worker(pending_queue, completed_queue) | ||
|
||
plugin_path, data = completed_queue.get() | ||
assert "vCenter" in data[1] | ||
|
||
|
||
def test_worker_with_invalid_plugin_path() -> None: | ||
"""Test the worker function when get_docstring has invalid plugin_path.""" | ||
pending_queue: multiprocessing.Queue[Any] = multiprocessing.Queue() | ||
completed_queue: multiprocessing.Queue[Any] = multiprocessing.Queue() | ||
|
||
plugin_path = Path("tests/fixtures/common/xyz.py") | ||
collection_name = "microsoft.ad" | ||
checksum = "12345" | ||
|
||
# Add an entry to the pending queue | ||
entry = collection_name, checksum, plugin_path | ||
pending_queue.put(entry) | ||
|
||
# Add a None entry to signal the end of processing | ||
pending_queue.put(None) | ||
|
||
worker(pending_queue, completed_queue) | ||
|
||
plugin_path, data = completed_queue.get() | ||
assert plugin_path == "error" | ||
assert "FileNotFoundError (get_docstring)" in data[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters