Mock open to /var/log/btmp and /var/log/wtmp

- btmp may not exist
- wtmp may not exist, or it may not contain ASCII data

Unbreaks tests on OpenBSD 6.2
This commit is contained in:
Eric Radman 2017-10-21 00:43:45 -04:00
parent 19a5383c59
commit 10d13062ec
No known key found for this signature in database
GPG key ID: 5C418B8631BC7C26
2 changed files with 8 additions and 4 deletions

View file

@ -59,8 +59,10 @@ class BTMPBeaconTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = btmp.beacon(config)
self.assertEqual(ret, [])
with patch('salt.utils.files.fopen', mock_open()) as m_open:
ret = btmp.beacon(config)
m_open.assert_called_with(btmp.BTMP, 'rb')
self.assertEqual(ret, [])
def test_match(self):
with patch('salt.utils.files.fopen',

View file

@ -60,8 +60,10 @@ class WTMPBeaconTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = wtmp.beacon(config)
self.assertEqual(ret, [])
with patch('salt.utils.files.fopen', mock_open()) as m_open:
ret = wtmp.beacon(config)
m_open.assert_called_with(wtmp.WTMP, 'rb')
self.assertEqual(ret, [])
def test_match(self):
with patch('salt.utils.files.fopen',