Skip to content

Commit

Permalink
Modify base tests for real module cases
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismeyersfsu committed Aug 28, 2024
1 parent 61f373d commit 5d2b347
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ relative_files = true
source =
tests
source_pkgs =
awx_plugins.credentials.x.api
awx_plugins.credentials
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ dependencies = [ # runtime deps # https://packaging.python.org/en/latest/guide
# GUIDANCE: only add things that this project imports directly
# GUIDANCE: only set lower version bounds
# "awx_plugins.base_interface.api", # keep `__init__.py` empty
"azure-identity", # credentials.azure_kv
"azure-keyvault", # credentials.azure_kv
"boto3", # credentials.awx_secretsmanager
"msrestazure", # credentials.azure_kv
"python-dsv-sdk >= 1.0.4", # credentials.thycotic_dsv
"python-tss-sdk >= 1.2.1", # credentials.thycotic_tss
"requests", # credentials.aim, credentials.centrify_vault, credentials.conjur, credentials.hashivault
]
classifiers = [ # Allowlist: https://pypi.org/classifiers/
"Development Status :: 1 - Planning",
Expand Down
5 changes: 0 additions & 5 deletions src/awx_plugins/credentials/x/api.py

This file was deleted.

37 changes: 26 additions & 11 deletions tests/importable_test.py
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}'

0 comments on commit 5d2b347

Please sign in to comment.