mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Making the switch to v2
This commit is contained in:
42
v1/tests/module_tests/TestApt.py
Normal file
42
v1/tests/module_tests/TestApt.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import collections
|
||||
import mock
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from ansible.modules.core.packaging.os.apt import (
|
||||
expand_pkgspec_from_fnmatches,
|
||||
)
|
||||
|
||||
|
||||
class AptExpandPkgspecTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
FakePackage = collections.namedtuple("Package", ("name",))
|
||||
self.fake_cache = [ FakePackage("apt"),
|
||||
FakePackage("apt-utils"),
|
||||
FakePackage("not-selected"),
|
||||
]
|
||||
|
||||
def test_trivial(self):
|
||||
foo = ["apt"]
|
||||
self.assertEqual(
|
||||
expand_pkgspec_from_fnmatches(None, foo, self.fake_cache), foo)
|
||||
|
||||
def test_version_wildcard(self):
|
||||
foo = ["apt=1.0*"]
|
||||
self.assertEqual(
|
||||
expand_pkgspec_from_fnmatches(None, foo, self.fake_cache), foo)
|
||||
|
||||
def test_pkgname_wildcard_version_wildcard(self):
|
||||
foo = ["apt*=1.0*"]
|
||||
m_mock = mock.Mock()
|
||||
self.assertEqual(
|
||||
expand_pkgspec_from_fnmatches(m_mock, foo, self.fake_cache),
|
||||
['apt', 'apt-utils'])
|
||||
|
||||
def test_pkgname_expands(self):
|
||||
foo = ["apt*"]
|
||||
m_mock = mock.Mock()
|
||||
self.assertEqual(
|
||||
expand_pkgspec_from_fnmatches(m_mock, foo, self.fake_cache),
|
||||
["apt", "apt-utils"])
|
||||
19
v1/tests/module_tests/TestDocker.py
Normal file
19
v1/tests/module_tests/TestDocker.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import collections
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from ansible.modules.core.cloud.docker.docker import get_split_image_tag
|
||||
|
||||
class DockerSplitImageTagTestCase(unittest.TestCase):
|
||||
|
||||
def test_trivial(self):
|
||||
self.assertEqual(get_split_image_tag('test'), ('test', 'latest'))
|
||||
|
||||
def test_with_org_name(self):
|
||||
self.assertEqual(get_split_image_tag('ansible/centos7-ansible'), ('ansible/centos7-ansible', 'latest'))
|
||||
|
||||
def test_with_tag(self):
|
||||
self.assertEqual(get_split_image_tag('test:devel'), ('test', 'devel'))
|
||||
|
||||
def test_with_tag_and_org_name(self):
|
||||
self.assertEqual(get_split_image_tag('ansible/centos7-ansible:devel'), ('ansible/centos7-ansible', 'devel'))
|
||||
Reference in New Issue
Block a user