-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify base tests for real module cases
- Loading branch information
1 parent
61f373d
commit 790f63c
Showing
4 changed files
with
34 additions
and
17 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 |
---|---|---|
|
@@ -31,4 +31,4 @@ relative_files = true | |
source = | ||
tests | ||
source_pkgs = | ||
awx_plugins.credentials.x.api | ||
awx_plugins |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,41 @@ | ||
"""Smoke tests related to loading entry points.""" | ||
|
||
import typing | ||
from importlib.metadata import entry_points as _discover_entry_points | ||
from subprocess import check_call as _invoke_command | ||
from sys import executable as _current_runtime | ||
|
||
import pytest | ||
|
||
|
||
EXPECTED_ENTRY_POINTS: list[tuple[str, str, str]] = [ | ||
('awx_plugins.credentials', 'aim', 'aim', 'aim_plugin'), | ||
('awx_plugins.credentials', 'conjur', 'conjur', 'conjur_plugin'), | ||
('awx_plugins.credentials', 'hashivault_kv', 'hashivault', 'hashivault_kv_plugin'), | ||
('awx_plugins.credentials', 'hashivault_ssh', 'hashivault', 'hashivault_ssh_plugin'), | ||
('awx_plugins.credentials', 'azure_kv', 'azure_kv', 'azure_keyvault_plugin'), | ||
('awx_plugins.credentials', 'centrify_vault_kv', 'centrify_vault', 'centrify_plugin'), | ||
('awx_plugins.credentials', 'thycotic_dsv', 'dsv', 'dsv_plugin'), | ||
('awx_plugins.credentials', 'thycotic_tss', 'tss', 'tss_plugin'), | ||
('awx_plugins.credentials', 'aws_secretsmanager_credential', 'aws_secretsmanager', 'aws_secretmanager_plugin'), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'entry_points_group', | ||
( | ||
'awx.credential_plugins', | ||
'awx_plugins.credentials', | ||
), | ||
'entry_points_group, expected_entry_point_name, expected_entry_point_module, expected_entry_point_func', | ||
EXPECTED_ENTRY_POINTS, | ||
) | ||
def test_entry_points_exposed(entry_points_group: str) -> None: | ||
def test_entry_points_exposed( | ||
entry_points_group: str, | ||
expected_entry_point_name: str, | ||
expected_entry_point_module: str, | ||
expected_entry_point_func: str, | ||
) -> None: | ||
"""Verify the plugin entry point is discoverable. | ||
This check relies on the plugin-declaring distribution package to be | ||
pre-installed. | ||
""" | ||
entry_points = _discover_entry_points(group=entry_points_group) | ||
assert 'x' in entry_points.names | ||
|
||
assert entry_points['x'].value == 'awx_plugins.credentials.x.api:XPlugin' | ||
|
||
assert callable(entry_points['x'].load()) | ||
assert expected_entry_point_name in entry_points.names | ||
assert entry_points[expected_entry_point_name].value == f'{entry_points_group}.{expected_entry_point_module}:{expected_entry_point_func}' |