def testinit(self): """ check the creation of a instance """ p1 = mylist([2, 3, 4]) expectedvalue = [2, 3, 4] result = p1.get() self.assertEqual(expectedvalue, result)
def testdivlist(self): """check the division by a integer the list except the first one""" p1 = ['serverId', 2, 4, 8] expectedvalue = ['serverId', 1, 2, 8] p1mylist = mylist(p1) result = p1mylist / 2 self.assertEqual(expectedvalue, result.data)
def testdivlistFloat(self): """check the division by a float the list except the first one""" p1 = ['serverId', 3, 5, 8] expectedvalue = ['serverId', 1.5, 2.5, 8] p1mylist = mylist(p1) result = p1mylist / 2 self.assertEqual(expectedvalue, result.data)
def testisdatafalse2(self): """testisdata should always return false due to p1 is mylist but the content is not a list""" p1 = mylist() p1.insert(1) expectedvalue = False result = mylist.isdata(p1) self.assertEqual(expectedvalue, result)
def testisdatatrue(self): """testisdatatrue should always return true due to p1 is mylist and the length is 3""" p1 = mylist() p1.insert([2, 3, 4]) expectedvalue = True result = mylist.isdata(p1) self.assertEqual(expectedvalue, result)
def testisdatafalse5(self): """testisdatafalse should always return false due to p1 is mylist but the length is not equal to 3""" p2 = mylist() expectedvalue = False p2.insert([1, 2, 3, 4]) result = mylist.isdata(p2) self.assertEqual(expectedvalue, result)
def testRealInsert2(self): """test insertion of real data""" expectedvalue = ['serverId', 1.0, 0.14, '2014-03-29T19:18:25.784424'] p1 = "[serverId, 1.0, 0.14, '2014-03-29T19:18:25.784424']" r1 = mylist() r1.insert(mylist.parselist(p1)) result = r1.get() self.assertEqual(expectedvalue, result)
def testinsert(self): """check the insertion of list of strings""" p1 = ['[serverId, 1, 2, 4]'] r1 = mylist() expectedvalue = [['serverId', 1, 2, '4']] r1.insert(p1) result = r1.get() self.assertEqual(expectedvalue, result)
def testDeleteAQueue(self): """test the insertion of a real data and delete the queue""" mylist_instance = mylist() fact = ['serverId', 1.0, 0.14, '2014-03-29T23:02:46.973949'] expected_initial_length = 2 expected_final_length = 0 p2 = list() p2.insert(0, fact) p2.insert(0, fact) mylist_instance.insert(p2) self.assertEqual(expected_initial_length, mylist_instance.__len__()) mylist_instance.delete() self.assertEqual(expected_final_length, mylist_instance.__len__())
def testInsertAnEmptyQueue(self): """test the insertion of a fake data with 0 items""" mylist_instance = mylist() expected_final = 0 response = mylist_instance.sum(0) self.assertEqual(expected_final, response)