mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Use self.setGrains as context manager in grains test
This commit is contained in:
parent
3d6c983c69
commit
e440d2e8af
@ -841,18 +841,18 @@ class GrainsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
|
||||
def test_append_convert_to_list_empty(self):
|
||||
# Append to an existing list
|
||||
self.setGrains({'foo': None})
|
||||
ret = grains.append(name='foo',
|
||||
value='baz',
|
||||
convert=True)
|
||||
self.assertEqual(ret['result'], True)
|
||||
self.assertEqual(ret['comment'], 'Value baz was added to grain foo')
|
||||
self.assertEqual(ret['changes'], {'added': 'baz'})
|
||||
self.assertEqual(
|
||||
grains.__grains__,
|
||||
{'foo': ['baz']})
|
||||
self.assertGrainFileContent("foo:\n"
|
||||
+ "- baz\n")
|
||||
with self.setGrains({'foo': None}):
|
||||
ret = grains.append(name='foo',
|
||||
value='baz',
|
||||
convert=True)
|
||||
self.assertEqual(ret['result'], True)
|
||||
self.assertEqual(ret['comment'], 'Value baz was added to grain foo')
|
||||
self.assertEqual(ret['changes'], {'added': 'baz'})
|
||||
self.assertEqual(
|
||||
grains.__grains__,
|
||||
{'foo': ['baz']})
|
||||
self.assertGrainFileContent("foo:\n"
|
||||
+ "- baz\n")
|
||||
|
||||
# 'list_present' function tests: 7
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user