1
0
Fork 0
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:
Ivo van Kreveld 2017-07-18 02:47:50 +02:00 committed by Matt Clay
parent 9a9c1c57bf
commit e976f299f8

View file

@ -245,43 +245,66 @@ class TestBase(unittest.TestCase):
self.assertEquals(variable_manager, self.b._variable_manager) 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): class TestExtendValue(unittest.TestCase):
def test_extend_value(self): # _extend_value could be a module or staticmethod but since its
# _extend_value could be a module or staticmethod but since its # not, the test is here.
# not, the test is here. def test_extend_value_list_newlist(self):
b = base.Base() b = base.Base()
value_list = ['first', 'second'] value_list = ['first', 'second']
new_value_list = ['new_first', 'new_second'] new_value_list = ['new_first', 'new_second']
ret = b._extend_value(value_list, new_value_list) ret = b._extend_value(value_list, new_value_list)
self.assertEquals(value_list + new_value_list, ret) 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) ret_prepend = b._extend_value(value_list, new_value_list, prepend=True)
self.assertEquals(new_value_list + value_list, ret_prepend) 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) ret = b._extend_value(new_value_list, value_list)
self.assertEquals(new_value_list + value_list, ret) 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) ret = b._extend_value(new_value_list, value_list, prepend=True)
self.assertEquals(value_list + new_value_list, ret) self.assertEquals(value_list + new_value_list, ret)
def test_extend_value_string_newlist(self):
b = base.Base()
some_string = 'some string' some_string = 'some string'
new_value_list = ['new_first', 'new_second']
ret = b._extend_value(some_string, new_value_list) ret = b._extend_value(some_string, new_value_list)
self.assertEquals([some_string] + new_value_list, ret) 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' new_value_string = 'this is the new values'
ret = b._extend_value(some_string, new_value_string) ret = b._extend_value(some_string, new_value_string)
self.assertEquals([some_string, new_value_string], ret) 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) ret = b._extend_value(value_list, new_value_string)
self.assertEquals(value_list + [new_value_string], ret) self.assertEquals(value_list + [new_value_string], ret)
def test_extend_value_none(self): def test_extend_value_none_none(self):
b = base.Base() b = base.Base()
ret = b._extend_value(None, None) ret = b._extend_value(None, None)
self.assertEquals(len(ret), 0) self.assertEquals(len(ret), 0)
self.assertFalse(ret) self.assertFalse(ret)
def test_extend_value_none_list(self):
b = base.Base()
ret = b._extend_value(None, ['foo']) ret = b._extend_value(None, ['foo'])
self.assertEquals(ret, ['foo']) self.assertEquals(ret, ['foo'])