Merge pull request #49020 from rallytime/fix-grains-test

Make grains integration test more robust
This commit is contained in:
Nicole Thomas 2018-08-08 16:59:18 -04:00 committed by GitHub
commit 6b6d68c615
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -163,16 +163,23 @@ class GrainsAppendTestCase(ModuleCase):
def test_grains_append_val_already_present(self):
'''
Tests the return of a grains.append call when the value is already present in the grains list.
Tests the return of a grains.append call when the value is already
present in the grains list.
'''
messaging = 'The val {0} was already in the list salttesting-grain-key'.format(self.GRAIN_VAL)
msg = 'The val {0} was already in the list ' \
'salttesting-grain-key'.format(self.GRAIN_VAL)
# First, make sure the test grain is present
self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
# Now try to append again
ret = self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
self.assertEqual(messaging, ret)
if not ret or isinstance(ret, dict):
# Sleep for a bit, sometimes the second "append" runs too quickly
time.sleep(5)
ret = self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
assert msg == ret
def test_grains_append_val_is_list(self):
'''