mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Update timezone module tests to reflect changes in mock_open
This commit is contained in:
parent
fc0aa9934f
commit
ed40371a06
@ -203,13 +203,11 @@ class TimezoneModuleTestCase(TestCase, LoaderModuleMockMixin):
|
||||
:return:
|
||||
'''
|
||||
with patch.dict(timezone.__grains__, {'os_family': ['Gentoo']}):
|
||||
_fopen = mock_open()
|
||||
with patch('salt.utils.files.fopen', _fopen):
|
||||
with patch('salt.utils.files.fopen', mock_open()) as m_open:
|
||||
assert timezone.set_zone(self.TEST_TZ)
|
||||
name, args, kwargs = _fopen.mock_calls[0]
|
||||
assert args == ('/etc/timezone', 'w')
|
||||
name, args, kwargs = _fopen.return_value.__enter__.return_value.write.mock_calls[0]
|
||||
assert args == ('UTC',)
|
||||
fh_ = m_open.filehandles['/etc/timezone'][0]
|
||||
assert fh_.call_args == ('/etc/timezone', 'w'), fh_.call_args
|
||||
assert fh_.write_calls == ['UTC', '\n'], fh_.write_calls
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'os.symlink not available in Windows')
|
||||
@patch('salt.utils.path.which', MagicMock(return_value=False))
|
||||
@ -222,13 +220,11 @@ class TimezoneModuleTestCase(TestCase, LoaderModuleMockMixin):
|
||||
:return:
|
||||
'''
|
||||
with patch.dict(timezone.__grains__, {'os_family': ['Debian']}):
|
||||
_fopen = mock_open()
|
||||
with patch('salt.utils.files.fopen', _fopen):
|
||||
with patch('salt.utils.files.fopen', mock_open()) as m_open:
|
||||
assert timezone.set_zone(self.TEST_TZ)
|
||||
name, args, kwargs = _fopen.mock_calls[0]
|
||||
assert args == ('/etc/timezone', 'w')
|
||||
name, args, kwargs = _fopen.return_value.__enter__.return_value.write.mock_calls[0]
|
||||
assert args == ('UTC',)
|
||||
fh_ = m_open.filehandles['/etc/timezone'][0]
|
||||
assert fh_.call_args == ('/etc/timezone', 'w'), fh_.call_args
|
||||
assert fh_.write_calls == ['UTC', '\n'], fh_.write_calls
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'os.symlink not available in Windows')
|
||||
@patch('salt.utils.path.which', MagicMock(return_value=True))
|
||||
|
Loading…
Reference in New Issue
Block a user