mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Merge pull request #52624 from tanlingyun2005/2019.2.1
fix TypeError: argument of type int is not iterable
This commit is contained in:
commit
9a1ed78cca
2 changed files with 11 additions and 3 deletions
|
@ -85,7 +85,7 @@ class Batch(object):
|
|||
'''
|
||||
partition = lambda x: float(x) / 100.0 * len(self.minions)
|
||||
try:
|
||||
if '%' in self.opts['batch']:
|
||||
if isinstance(self.opts['batch'], six.string_types) and '%' in self.opts['batch']:
|
||||
res = partition(float(self.opts['batch'].strip('%')))
|
||||
if res < 1:
|
||||
return int(math.ceil(res))
|
||||
|
|
|
@ -35,14 +35,22 @@ class BatchTestCase(TestCase):
|
|||
|
||||
# get_bnum tests
|
||||
|
||||
def test_get_bnum(self):
|
||||
def test_get_bnum_str(self):
|
||||
'''
|
||||
Tests passing batch value as a number
|
||||
Tests passing batch value as a number(str)
|
||||
'''
|
||||
self.batch.opts = {'batch': '2', 'timeout': 5}
|
||||
self.batch.minions = ['foo', 'bar']
|
||||
self.assertEqual(Batch.get_bnum(self.batch), 2)
|
||||
|
||||
def test_get_bnum_int(self):
|
||||
'''
|
||||
Tests passing batch value as a number(int)
|
||||
'''
|
||||
self.batch.opts = {'batch': 2, 'timeout': 5}
|
||||
self.batch.minions = ['foo', 'bar']
|
||||
self.assertEqual(Batch.get_bnum(self.batch), 2)
|
||||
|
||||
def test_get_bnum_percentage(self):
|
||||
'''
|
||||
Tests passing batch value as percentage
|
||||
|
|
Loading…
Add table
Reference in a new issue