"Fossies" - the Fresh Open Source Software Archive 
Member "salt-3002.2/tests/unit/states/test_aptpkg.py" (18 Nov 2020, 955 Bytes) of package /linux/misc/salt-3002.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "test_aptpkg.py":
3002.1_vs_3002.2.
1 """
2 :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
3 """
4
5
6 import salt.states.aptpkg as aptpkg
7 from tests.support.mixins import LoaderModuleMockMixin
8 from tests.support.mock import MagicMock, patch
9 from tests.support.unit import TestCase
10
11
12 class AptTestCase(TestCase, LoaderModuleMockMixin):
13 """
14 Test cases for salt.states.aptpkg
15 """
16
17 def setup_loader_modules(self):
18 return {aptpkg: {}}
19
20 # 'held' function tests: 1
21
22 def test_held(self):
23 """
24 Test to set package in 'hold' state, meaning it will not be upgraded.
25 """
26 name = "tmux"
27
28 ret = {
29 "name": name,
30 "result": False,
31 "changes": {},
32 "comment": "Package {} does not have a state".format(name),
33 }
34
35 mock = MagicMock(return_value=False)
36 with patch.dict(aptpkg.__salt__, {"pkg.get_selections": mock}):
37 self.assertDictEqual(aptpkg.held(name), ret)