mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Update mock_open usage to reflect read_data type enforcement
This commit is contained in:
parent
374a8ce31f
commit
a13d1fe1a0
5 changed files with 5 additions and 7 deletions
|
@ -56,7 +56,7 @@ class BTMPBeaconTestCase(TestCase, LoaderModuleMockMixin):
|
|||
|
||||
self.assertEqual(ret, (True, 'Valid beacon configuration'))
|
||||
|
||||
with patch('salt.utils.files.fopen', mock_open()) as m_open:
|
||||
with patch('salt.utils.files.fopen', mock_open(b'')) as m_open:
|
||||
ret = btmp.beacon(config)
|
||||
call_args = next(six.itervalues(m_open.filehandles))[0].call.args
|
||||
assert call_args == (btmp.BTMP, 'rb'), call_args
|
||||
|
|
|
@ -56,7 +56,7 @@ class WTMPBeaconTestCase(TestCase, LoaderModuleMockMixin):
|
|||
|
||||
self.assertEqual(ret, (True, 'Valid beacon configuration'))
|
||||
|
||||
with patch('salt.utils.files.fopen', mock_open()) as m_open:
|
||||
with patch('salt.utils.files.fopen', mock_open(b'')) as m_open:
|
||||
ret = wtmp.beacon(config)
|
||||
call_args = next(six.itervalues(m_open.filehandles))[0].call.args
|
||||
assert call_args == (wtmp.WTMP, 'rb'), call_args
|
||||
|
|
|
@ -114,7 +114,7 @@ class HostsTestCase(TestCase, LoaderModuleMockMixin):
|
|||
with patch('salt.modules.hosts.__get_hosts_filename',
|
||||
MagicMock(return_value='/etc/hosts')), \
|
||||
patch('os.path.isfile', MagicMock(return_value=True)), \
|
||||
patch('salt.utils.files.fopen', mock_open()):
|
||||
patch('salt.utils.files.fopen', mock_open(b'')):
|
||||
mock_opt = MagicMock(return_value=None)
|
||||
with patch.dict(hosts.__salt__, {'config.option': mock_opt}):
|
||||
self.assertTrue(hosts.set_host('10.10.10.10', 'Salt1'))
|
||||
|
@ -212,7 +212,7 @@ class HostsTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
Tests if specified host entry gets removed from the hosts file
|
||||
'''
|
||||
with patch('salt.utils.files.fopen', mock_open()), \
|
||||
with patch('salt.utils.files.fopen', mock_open(b'')), \
|
||||
patch('salt.modules.hosts.__get_hosts_filename',
|
||||
MagicMock(return_value='/etc/hosts')), \
|
||||
patch('salt.modules.hosts.has_pair',
|
||||
|
|
|
@ -900,7 +900,7 @@ class StateTestCase(TestCase, LoaderModuleMockMixin):
|
|||
mock):
|
||||
with patch(
|
||||
'salt.utils.files.fopen',
|
||||
mock_open()):
|
||||
mock_open(b'')):
|
||||
self.assertTrue(
|
||||
state.sls(arg,
|
||||
None,
|
||||
|
|
|
@ -75,13 +75,11 @@ class SSHConfigRosterTestCase(TestCase, mixins.LoaderModuleMockMixin):
|
|||
def test_all(self):
|
||||
with mock.patch('salt.utils.files.fopen', self.mock_fp):
|
||||
with mock.patch('salt.roster.sshconfig._get_ssh_config_file'):
|
||||
self.mock_fp.return_value.__iter__.return_value = _SAMPLE_SSH_CONFIG.splitlines()
|
||||
targets = sshconfig.targets('*')
|
||||
self.assertEqual(targets, _ALL)
|
||||
|
||||
def test_abc_glob(self):
|
||||
with mock.patch('salt.utils.files.fopen', self.mock_fp):
|
||||
with mock.patch('salt.roster.sshconfig._get_ssh_config_file'):
|
||||
self.mock_fp.return_value.__iter__.return_value = _SAMPLE_SSH_CONFIG.splitlines()
|
||||
targets = sshconfig.targets('abc*')
|
||||
self.assertEqual(targets, _ABC_GLOB)
|
||||
|
|
Loading…
Add table
Reference in a new issue