2017-07-20 23:53:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-08-19 00:24:30 +00:00
|
|
|
'''Unit test for saltcheck execution module'''
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-08-30 20:44:25 +00:00
|
|
|
# Import Python libs
|
2018-01-24 20:47:14 +00:00
|
|
|
from __future__ import absolute_import, unicode_literals, print_function
|
2017-09-11 14:19:42 +00:00
|
|
|
import os.path
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-08-19 00:45:17 +00:00
|
|
|
try:
|
|
|
|
import salt.modules.saltcheck as saltcheck
|
2017-09-11 14:19:42 +00:00
|
|
|
import salt.config
|
|
|
|
import salt.syspaths as syspaths
|
2017-08-30 20:44:25 +00:00
|
|
|
except:
|
|
|
|
raise
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-08-30 20:44:25 +00:00
|
|
|
# Import Salt Testing Libs
|
|
|
|
try:
|
|
|
|
from tests.support.mixins import LoaderModuleMockMixin
|
|
|
|
from tests.support.unit import skipIf, TestCase
|
|
|
|
from tests.support.mock import (
|
|
|
|
MagicMock,
|
|
|
|
patch,
|
|
|
|
NO_MOCK,
|
|
|
|
NO_MOCK_REASON
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
|
|
|
class LinuxSysctlTestCase(TestCase, LoaderModuleMockMixin):
|
|
|
|
'''
|
|
|
|
TestCase for salt.modules.saltcheck module
|
|
|
|
'''
|
|
|
|
|
|
|
|
def setup_loader_modules(self):
|
2017-09-11 14:19:42 +00:00
|
|
|
# Setting the environment to be local
|
|
|
|
local_opts = salt.config.minion_config(
|
2017-12-13 22:31:04 +00:00
|
|
|
os.path.join(syspaths.CONFIG_DIR, 'minion'))
|
2017-09-13 09:09:44 +00:00
|
|
|
local_opts['file_client'] = 'local'
|
2017-09-11 14:19:42 +00:00
|
|
|
patcher = patch('salt.config.minion_config',
|
|
|
|
MagicMock(return_value=local_opts))
|
|
|
|
patcher.start()
|
|
|
|
self.addCleanup(patcher.stop)
|
2017-08-30 20:44:25 +00:00
|
|
|
return {saltcheck: {}}
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-07-21 17:11:27 +00:00
|
|
|
def test_call_salt_command(self):
|
2017-08-19 00:24:30 +00:00
|
|
|
'''test simple test.echo module'''
|
2017-07-25 21:11:25 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
2017-07-26 22:00:15 +00:00
|
|
|
'sys.list_modules': MagicMock(return_value=['module1']),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
returned = sc_instance.call_salt_command(fun="test.echo", args=['hello'], kwargs=None)
|
2017-07-25 21:11:25 +00:00
|
|
|
self.assertEqual(returned, 'hello')
|
|
|
|
|
2017-08-30 20:44:25 +00:00
|
|
|
def test_update_master_cache(self):
|
|
|
|
'''test master cache'''
|
|
|
|
self.assertTrue(saltcheck.update_master_cache)
|
|
|
|
|
2017-07-25 21:11:25 +00:00
|
|
|
def test_call_salt_command2(self):
|
2017-08-19 00:24:30 +00:00
|
|
|
'''test simple test.echo module again'''
|
2017-07-25 21:11:25 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
2017-07-26 22:00:15 +00:00
|
|
|
'sys.list_modules': MagicMock(return_value=['module1']),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
returned = sc_instance.call_salt_command(fun="test.echo", args=['hello'], kwargs=None)
|
2017-07-25 21:11:25 +00:00
|
|
|
self.assertNotEqual(returned, 'not-hello')
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_equal1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = {'a': 1, 'b': 2}
|
|
|
|
bbb = {'a': 1, 'b': 2}
|
|
|
|
mybool = sc_instance._SaltCheck__assert_equal(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_equal2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
mybool = sc_instance._SaltCheck__assert_equal(False, True)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_not_equal1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = {'a': 1, 'b': 2}
|
|
|
|
bbb = {'a': 1, 'b': 2, 'c': 3}
|
|
|
|
mybool = sc_instance._SaltCheck__assert_not_equal(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_not_equal2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = {'a': 1, 'b': 2}
|
|
|
|
bbb = {'a': 1, 'b': 2}
|
|
|
|
mybool = sc_instance._SaltCheck__assert_not_equal(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_true1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
mybool = sc_instance._SaltCheck__assert_equal(True, True)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_true2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
mybool = sc_instance._SaltCheck__assert_equal(False, True)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_false1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
mybool = sc_instance._SaltCheck__assert_false(False)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_false2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
mybool = sc_instance._SaltCheck__assert_false(True)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_in1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = "bob"
|
2017-07-26 22:00:15 +00:00
|
|
|
mylist = ['alice', 'bob', 'charles', 'dana']
|
2017-08-19 00:45:17 +00:00
|
|
|
mybool = sc_instance._SaltCheck__assert_in(aaa, mylist)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_in2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = "elaine"
|
2017-07-26 22:00:15 +00:00
|
|
|
mylist = ['alice', 'bob', 'charles', 'dana']
|
2017-08-19 00:45:17 +00:00
|
|
|
mybool = sc_instance._SaltCheck__assert_in(aaa, mylist)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_not_in1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = "elaine"
|
2017-07-26 22:00:15 +00:00
|
|
|
mylist = ['alice', 'bob', 'charles', 'dana']
|
2017-08-19 00:45:17 +00:00
|
|
|
mybool = sc_instance._SaltCheck__assert_not_in(aaa, mylist)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_not_in2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = "bob"
|
2017-07-26 22:00:15 +00:00
|
|
|
mylist = ['alice', 'bob', 'charles', 'dana']
|
2017-08-19 00:45:17 +00:00
|
|
|
mybool = sc_instance._SaltCheck__assert_not_in(aaa, mylist)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_greater1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 110
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_greater(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_greater2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 100
|
|
|
|
bbb = 110
|
|
|
|
mybool = sc_instance._SaltCheck__assert_greater(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_greater3(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 100
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_greater(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
2017-08-19 00:45:17 +00:00
|
|
|
def test__assert_greater_equal1(self):
|
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 110
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_greater_equal(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_greater_equal2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 100
|
|
|
|
bbb = 110
|
|
|
|
mybool = sc_instance._SaltCheck__assert_greater_equal(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_greater_equal3(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 100
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_greater_equal(aaa, bbb)
|
2017-07-27 21:33:16 +00:00
|
|
|
self.assertEqual(mybool, 'Pass')
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_less1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 99
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_less(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool, True)
|
2017-07-21 17:11:27 +00:00
|
|
|
|
|
|
|
def test__assert_less2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 110
|
|
|
|
bbb = 99
|
|
|
|
mybool = sc_instance._SaltCheck__assert_less(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-07-21 17:11:27 +00:00
|
|
|
def test__assert_less3(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 100
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_less(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-07-21 17:11:27 +00:00
|
|
|
def test__assert_less_equal1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 99
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_less_equal(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertTrue(mybool, True)
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-07-21 17:11:27 +00:00
|
|
|
def test__assert_less_equal2(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 110
|
|
|
|
bbb = 99
|
|
|
|
mybool = sc_instance._SaltCheck__assert_less_equal(aaa, bbb)
|
2017-07-26 22:00:15 +00:00
|
|
|
self.assertNotEqual(mybool, True)
|
2017-07-20 23:53:45 +00:00
|
|
|
|
2017-07-21 17:11:27 +00:00
|
|
|
def test__assert_less_equal3(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'cp.cache_master': MagicMock(return_value=[True])
|
2017-08-19 00:24:30 +00:00
|
|
|
}):
|
2017-08-19 00:45:17 +00:00
|
|
|
sc_instance = saltcheck.SaltCheck()
|
|
|
|
aaa = 100
|
|
|
|
bbb = 100
|
|
|
|
mybool = sc_instance._SaltCheck__assert_less_equal(aaa, bbb)
|
2017-07-27 21:33:16 +00:00
|
|
|
self.assertEqual(mybool, 'Pass')
|
2017-07-26 22:00:15 +00:00
|
|
|
|
|
|
|
def test_run_test_1(self):
|
2017-08-19 00:45:17 +00:00
|
|
|
'''test'''
|
2017-07-26 22:00:15 +00:00
|
|
|
with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value=True),
|
|
|
|
'sys.list_modules': MagicMock(return_value=['test']),
|
|
|
|
'sys.list_functions': MagicMock(return_value=['test.echo']),
|
2017-08-19 00:24:30 +00:00
|
|
|
'cp.cache_master': MagicMock(return_value=[True])}):
|
|
|
|
returned = saltcheck.run_test(test={"module_and_function": "test.echo",
|
|
|
|
"assertion": "assertEqual",
|
|
|
|
"expected-return": "This works!",
|
|
|
|
"args": ["This works!"]
|
|
|
|
})
|
2017-07-27 21:33:16 +00:00
|
|
|
self.assertEqual(returned, 'Pass')
|