Add unit test for file.line on an empty content while not deleting anything

This commit is contained in:
Bo Maryniuk 2017-10-30 13:48:22 +01:00
parent b5a80231bd
commit f0f08a10e8

View File

@ -872,6 +872,18 @@ class FileModuleTestCase(TestCase, LoaderModuleMockMixin):
assert err_msg in str(cmd_err)
@skipIf(pytest is None, 'PyTest required for this test')
@patch('os.path.realpath', MagicMock())
@patch('os.path.isfile', MagicMock(return_value=True))
def test_line_no_content(self):
'''
Test for file.line for an empty content when not deleting anything.
:return:
'''
for mode in ['insert', 'ensure', 'replace']:
with pytest.raises(CommandExecutionError) as cmd_err:
filemod.line('foo', mode=mode)
assert 'Content can only be empty if mode is "delete"' in str(cmd_err)
class FileBasicsTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):