Пример #1
0
 def test_ListItem_add_item_multiple(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     newValues = ["newValue1", "newValue2"]
     addRet = newitem.add(newValues)
     assert addRet is True
     assert all(elem in newitem.value for elem in newValues)
Пример #2
0
 def test_ListItem_add_item_dublicate_list_partial(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     newValues = ["InitValue3", "newValue1", "newValue2"]
     addRet = newitem.add(newValues)
     assert addRet is True
     assert all(elem in newitem.value for elem in newValues)
     assert newitem.value.count("InitValue3") == 1
Пример #3
0
 def test_ListItem_replace_item_byValue(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     newValue = "newValue"
     val2replace = "InitValue2"
     oldindex = newitem.value.index(val2replace)
     assert newitem.value[oldindex] == val2replace
Пример #4
0
 def test_ListItem_remove_item_byValue(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     newitem.remove("InitValue2")
     assert "InitValue2" not in newitem.value
Пример #5
0
 def test_ListItem_replace_item_Raise_TypError_new(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     newValue = "newValue"
     with self.assertRaises(TypeError):
         newitem.replace("InitValue1", {})
Пример #6
0
 def test_ListItem_remove_item_Raise_TypError(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     with self.assertRaises(TypeError):
         newitem.remove(2.567)
Пример #7
0
 def test_ListItem_add_item_dublicate_list(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     addRet = newitem.add(["InitValue3", "InitValue2"])
     assert addRet is False
Пример #8
0
 def test_ListItem_add_item(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     with self.assertRaises(TypeError):
         addRet = newitem.add(3.1415)
Пример #9
0
 def test_ListItem_add_item(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     addRet = newitem.add("newValue")
     assert addRet is True
     assert "newValue" in newitem.value
Пример #10
0
 def test_initialization_list_exeption_type(self):
     with self.assertRaises(TypeError):
         ListItem("TestName", {})
Пример #11
0
 def test_initialization_list_fromString(self):
     newitem = ListItem("TestName", "TestValue")
     assert newitem.name == "TestName"
     assert isinstance(newitem.value, list)
     assert newitem.value[0] == "TestValue"
Пример #12
0
 def test_ListItem_remove_item_byIndex_Raise_IndexError(self):
     values = ["InitValue1", "InitValue2", "InitValue3"]
     newitem = ListItem("TestName", values)
     with self.assertRaises(IndexError):
         newitem.remove(3)
Пример #13
0
 def test_ListItem_remove_item_byIndex(self):
     values = ["InitValue1", "InitValue2", "InitValue3"]
     newitem = ListItem("TestName", values)
     oldValue = values[0]
     newitem.remove(0)
     assert oldValue not in newitem.value
Пример #14
0
 def test_ListItem_remove_item_byValue_fail(self):
     newitem = ListItem("TestName",
                        ["InitValue1", "InitValue2", "InitValue3"])
     with self.assertRaises(ValueError):
         newitem.remove("InitValue5")