salt/tests/unit/states/test_pkgng.py

45 lines
1.1 KiB
Python
Raw Normal View History

2015-05-27 09:24:19 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
'''
# Import Python libs
from __future__ import absolute_import
# Import Salt Testing Libs
2017-03-22 16:42:17 +00:00
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import skipIf, TestCase
from tests.support.mock import (
2015-05-27 09:24:19 +00:00
NO_MOCK,
NO_MOCK_REASON,
MagicMock,
patch)
# Import Salt Libs
import salt.states.pkgng as pkgng
2015-05-27 09:24:19 +00:00
@skipIf(NO_MOCK, NO_MOCK_REASON)
2017-03-22 16:42:17 +00:00
class PkgngTestCase(TestCase, LoaderModuleMockMixin):
2015-05-27 09:24:19 +00:00
'''
Test cases for salt.states.pkgng
'''
2017-03-22 16:42:17 +00:00
def setup_loader_modules(self):
return {pkgng: {}}
2015-05-27 09:24:19 +00:00
# 'update_packaging_site' function tests: 1
def test_update_packaging_site(self):
'''
Test to execute update_packaging_site.
'''
name = "http://192.168.0.2"
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
mock_t = MagicMock(return_value=True)
with patch.dict(pkgng.__salt__, {'pkgng.update_package_site': mock_t}):
self.assertDictEqual(pkgng.update_packaging_site(name), ret)