mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Divided test methods of TestExtendValue class (#22574)
Divided the two test methods of the TestExtendValue class into multiple test methods so there is a test method for each compare.
This commit is contained in:
parent
9a9c1c57bf
commit
e976f299f8
1 changed files with 28 additions and 5 deletions
|
@ -245,43 +245,66 @@ class TestBase(unittest.TestCase):
|
|||
self.assertEquals(variable_manager, self.b._variable_manager)
|
||||
|
||||
|
||||
# TODO/FIXME: test methods for each of the compares would be more precise
|
||||
class TestExtendValue(unittest.TestCase):
|
||||
def test_extend_value(self):
|
||||
# _extend_value could be a module or staticmethod but since its
|
||||
# not, the test is here.
|
||||
# _extend_value could be a module or staticmethod but since its
|
||||
# not, the test is here.
|
||||
def test_extend_value_list_newlist(self):
|
||||
b = base.Base()
|
||||
value_list = ['first', 'second']
|
||||
new_value_list = ['new_first', 'new_second']
|
||||
ret = b._extend_value(value_list, new_value_list)
|
||||
self.assertEquals(value_list + new_value_list, ret)
|
||||
|
||||
def test_extend_value_list_newlist_prepend(self):
|
||||
b = base.Base()
|
||||
value_list = ['first', 'second']
|
||||
new_value_list = ['new_first', 'new_second']
|
||||
ret_prepend = b._extend_value(value_list, new_value_list, prepend=True)
|
||||
self.assertEquals(new_value_list + value_list, ret_prepend)
|
||||
|
||||
def test_extend_value_newlist_list(self):
|
||||
b = base.Base()
|
||||
value_list = ['first', 'second']
|
||||
new_value_list = ['new_first', 'new_second']
|
||||
ret = b._extend_value(new_value_list, value_list)
|
||||
self.assertEquals(new_value_list + value_list, ret)
|
||||
|
||||
def test_extend_value_newlist_list_prepend(self):
|
||||
b = base.Base()
|
||||
value_list = ['first', 'second']
|
||||
new_value_list = ['new_first', 'new_second']
|
||||
ret = b._extend_value(new_value_list, value_list, prepend=True)
|
||||
self.assertEquals(value_list + new_value_list, ret)
|
||||
|
||||
def test_extend_value_string_newlist(self):
|
||||
b = base.Base()
|
||||
some_string = 'some string'
|
||||
new_value_list = ['new_first', 'new_second']
|
||||
ret = b._extend_value(some_string, new_value_list)
|
||||
self.assertEquals([some_string] + new_value_list, ret)
|
||||
|
||||
def test_extend_value_string_newstring(self):
|
||||
b = base.Base()
|
||||
some_string = 'some string'
|
||||
new_value_string = 'this is the new values'
|
||||
ret = b._extend_value(some_string, new_value_string)
|
||||
self.assertEquals([some_string, new_value_string], ret)
|
||||
|
||||
def test_extend_value_list_newstring(self):
|
||||
b = base.Base()
|
||||
value_list = ['first', 'second']
|
||||
new_value_string = 'this is the new values'
|
||||
ret = b._extend_value(value_list, new_value_string)
|
||||
self.assertEquals(value_list + [new_value_string], ret)
|
||||
|
||||
def test_extend_value_none(self):
|
||||
def test_extend_value_none_none(self):
|
||||
b = base.Base()
|
||||
ret = b._extend_value(None, None)
|
||||
self.assertEquals(len(ret), 0)
|
||||
self.assertFalse(ret)
|
||||
|
||||
def test_extend_value_none_list(self):
|
||||
b = base.Base()
|
||||
ret = b._extend_value(None, ['foo'])
|
||||
self.assertEquals(ret, ['foo'])
|
||||
|
||||
|
|
Loading…
Reference in a new issue