diff options
author | Sviatoslav Sydorenko <webknjaz@redhat.com> | 2021-02-12 03:23:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-11 18:23:57 -0800 |
commit | f327e65d11bb905ed9f15996024f857a95592629 (patch) | |
tree | bf31b3ea4fc5475c3f4e6ccefe2c0e7573ef117b /test/units | |
parent | f533d46572113655a0a698beab4b38671744a458 (diff) | |
download | ansible-f327e65d11bb905ed9f15996024f857a95592629.tar.gz |
Use iskeyword and str.isidentifier for "is FQCN" (#73279)
* Use valid FQCN in test_verbosity_arguments
* Use iskeyword and str.isidentifier for "is FQCN"
Diffstat (limited to 'test/units')
-rw-r--r-- | test/units/cli/test_galaxy.py | 10 | ||||
-rw-r--r-- | test/units/utils/collection_loader/test_collection_loader.py | 19 |
2 files changed, 24 insertions, 5 deletions
diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py index 4b2560adbd..804e1345d5 100644 --- a/test/units/cli/test_galaxy.py +++ b/test/units/cli/test_galaxy.py @@ -460,13 +460,13 @@ class TestGalaxyInitSkeleton(unittest.TestCase, ValidRoleTests): @pytest.mark.parametrize('cli_args, expected', [ - (['ansible-galaxy', 'collection', 'init', 'abc.def'], 0), - (['ansible-galaxy', 'collection', 'init', 'abc.def', '-vvv'], 3), - (['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def'], 2), + (['ansible-galaxy', 'collection', 'init', 'abc._def'], 0), + (['ansible-galaxy', 'collection', 'init', 'abc._def', '-vvv'], 3), + (['ansible-galaxy', '-vv', 'collection', 'init', 'abc._def'], 2), # Due to our manual parsing we want to verify that -v set in the sub parser takes precedence. This behaviour is # deprecated and tests should be removed when the code that handles it is removed - (['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-v'], 1), - (['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-vvvv'], 4), + (['ansible-galaxy', '-vv', 'collection', 'init', 'abc._def', '-v'], 1), + (['ansible-galaxy', '-vv', 'collection', 'init', 'abc._def', '-vvvv'], 4), (['ansible-galaxy', '-vvv', 'init', 'name'], 3), (['ansible-galaxy', '-vvvvv', 'init', '-v', 'name'], 1), ]) diff --git a/test/units/utils/collection_loader/test_collection_loader.py b/test/units/utils/collection_loader/test_collection_loader.py index a2bee819a1..c8187676e6 100644 --- a/test/units/utils/collection_loader/test_collection_loader.py +++ b/test/units/utils/collection_loader/test_collection_loader.py @@ -719,6 +719,25 @@ def test_fqcr_parsing_valid(ref, ref_type, expected_collection, @pytest.mark.parametrize( + ('fqcn', 'expected'), + ( + ('ns1.coll2', True), + ('def.coll3', False), + ('ns4.return', False), + ('assert.this', False), + ('import.that', False), + ('.that', False), + ('this.', False), + ('.', False), + ('', False), + ), +) +def test_fqcn_validation(fqcn, expected): + """Vefiry that is_valid_collection_name validates FQCN correctly.""" + assert AnsibleCollectionRef.is_valid_collection_name(fqcn) is expected + + +@pytest.mark.parametrize( 'ref,ref_type,expected_error_type,expected_error_expression', [ ('no_dots_at_all_action', 'action', ValueError, 'is not a valid collection reference'), |