generated from ansible-community/project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for new Credential private api class
- Loading branch information
1 parent
44e9b2c
commit 86e3b6b
Showing
2 changed files
with
50 additions
and
2 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
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,45 @@ | ||
"""Tests for the temporarily hosted private helpers.""" | ||
|
||
import pytest | ||
|
||
from awx_plugins.interfaces._temporary_private_credential_api import ( | ||
Credential, | ||
GenericOptionalPrimitiveType, | ||
) | ||
|
||
|
||
def test_credential_instantiation() -> None: | ||
"""Check that credential type can be instantiated.""" | ||
assert Credential() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
('inputs', 'key', 'expected'), | ||
( | ||
({'foo': 'bar'}, 'foo', 'bar'), | ||
({'foo1': 'bar1'}, 'baz', None), | ||
), | ||
) | ||
def test_credential_get_input( | ||
inputs: dict[str, GenericOptionalPrimitiveType], | ||
key: str, | ||
expected: str, | ||
) -> None: | ||
"""Check that get_input operates on the dict we provided.""" | ||
assert Credential(inputs=inputs).get_input(key) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
('inputs', 'key', 'expected'), | ||
( | ||
({'foo2': 'bar2'}, 'foo2', True), | ||
({'foo3': 'bar3'}, 'baz', False), | ||
), | ||
) | ||
def test_credential_has_input( | ||
inputs: dict[str, GenericOptionalPrimitiveType], | ||
key: str, | ||
expected: bool, | ||
) -> None: | ||
"""Check that has_input behaves like dict in operator.""" | ||
assert Credential(inputs=inputs).has_input(key) == expected |