mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Adding a test for __skip_source
This commit is contained in:
parent
7c70497eeb
commit
5133f0d4b9
1 changed files with 49 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import textwrap
|
||||
|
||||
import salt.modules.aptpkg as aptpkg
|
||||
|
@ -28,6 +29,8 @@ try:
|
|||
except ImportError:
|
||||
pytest = None
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
APT_KEY_LIST = r"""
|
||||
pub:-:1024:17:46181433FBB75451:1104433784:::-:::scSC:
|
||||
|
@ -153,6 +156,17 @@ Reading state information...
|
|||
UNINSTALL = {"tmux": {"new": six.text_type(), "old": "1.8-5"}}
|
||||
|
||||
|
||||
class MockSourceEntry(object):
|
||||
def __init__(self, uri, source_type, line, invalid):
|
||||
self.uri = uri
|
||||
self.type = source_type
|
||||
self.line = line
|
||||
self.invalid = invalid
|
||||
|
||||
def mysplit(self, line):
|
||||
return line.split()
|
||||
|
||||
|
||||
class AptPkgTestCase(TestCase, LoaderModuleMockMixin):
|
||||
"""
|
||||
Test cases for salt.modules.aptpkg
|
||||
|
@ -595,6 +609,41 @@ class AptPkgTestCase(TestCase, LoaderModuleMockMixin):
|
|||
self.assertEqual(len(list_downloaded), 1)
|
||||
self.assertDictEqual(list_downloaded, DOWNLOADED_RET)
|
||||
|
||||
def test__skip_source(self):
|
||||
'''
|
||||
Test __skip_source.
|
||||
:return:
|
||||
'''
|
||||
# Valid source
|
||||
source_type = 'deb'
|
||||
source_uri = 'http://cdn-aws.deb.debian.org/debian'
|
||||
source_line = 'deb http://cdn-aws.deb.debian.org/debian stretch main\n'
|
||||
|
||||
mock_source = MockSourceEntry(source_uri, source_type, source_line, False)
|
||||
|
||||
ret = aptpkg._skip_source(mock_source)
|
||||
self.assertFalse(ret)
|
||||
|
||||
# Invalid source type
|
||||
source_type = 'ded'
|
||||
source_uri = 'http://cdn-aws.deb.debian.org/debian'
|
||||
source_line = 'deb http://cdn-aws.deb.debian.org/debian stretch main\n'
|
||||
|
||||
mock_source = MockSourceEntry(source_uri, source_type, source_line, True)
|
||||
|
||||
ret = aptpkg._skip_source(mock_source)
|
||||
self.assertTrue(ret)
|
||||
|
||||
# Invalid source type , not skipped
|
||||
source_type = 'deb'
|
||||
source_uri = 'http://cdn-aws.deb.debian.org/debian'
|
||||
source_line = 'deb [http://cdn-aws.deb.debian.org/debian] stretch main\n'
|
||||
|
||||
mock_source = MockSourceEntry(source_uri, source_type, source_line, True)
|
||||
|
||||
ret = aptpkg._skip_source(mock_source)
|
||||
self.assertFalse(ret)
|
||||
|
||||
|
||||
@skipIf(pytest is None, "PyTest is missing")
|
||||
class AptUtilsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
|
|
Loading…
Add table
Reference in a new issue