def test_sanity_check(self): """ Checks out if the initial elements that'll be appended into the file are equals to the elements returned by the get_entry method. """ append_entry(self.path, self.el1) append_entry(self.path, self.el2) el1 = get_entry(self.path, 0) el2 = get_entry(self.path, 1) self.assertEqual(el1, self.el1) self.assertEqual(el2, self.el2)
def test_append_and_remove_entry(self): """ Checks out if after removing entries the remained elements are corrects """ for i in range(10): append_entry(self.path, self.el1) append_entry(self.path, self.el2) num_el_to_remove = random.randint(0, 19) for i in range(num_el_to_remove): remove_entry(self.path, random.randint(0, get_len(self.path) - 1)) self.assertEqual(20 - num_el_to_remove, get_len(self.path))
def test_append_and_remove_entry(self): """ Checks out if after removing entries the remained elements are corrects """ for i in range(10): append_entry(self.path, self.el1) append_entry(self.path, self.el2) num_el_to_remove = random.randint(0,19) for i in range(num_el_to_remove): remove_entry(self.path, random.randint(0, get_len(self.path)-1)) self.assertEqual(20-num_el_to_remove, get_len(self.path))
def test_out_of_range(self): """ Checks out if the index specified by the user is out of range raising the exception """ append_entry(self.path, self.el1) append_entry(self.path, self.el2) append_entry(self.path, self.el1) append_entry(self.path, self.el2) self.assertRaises(IndexError, get_entry, self.path, -1) self.assertRaises(IndexError, get_entry, self.path, 4) self.assertRaises(IndexError, remove_entry, self.path, -1) self.assertRaises(IndexError, remove_entry, self.path, 4) pass