def test_add_object_correct(self): """ Add object with new obj_id """ a = OA.testobject("Brommer", "d", "power", flag_verbose = self.flag_verbose) result = self.oa.add_object(a, flag_verbose = self.flag_verbose) self.assertTrue(["a", "b", "c", "d"] == self.oa.obj_id_array and result == True)
def setUp(self): """ Set up an objectarray object for reuse in the tests. Toggle verbose using the command line. """ self.flag_verbose = args.verbose self.oa = OA.objectarray("test") a = OA.testobject("Auto", "a", "power", flag_verbose = self.flag_verbose) b = OA.testobject("Boot", "b", "power", flag_verbose = self.flag_verbose) c = OA.testobject("Fiets", "c", "human", flag_verbose = self.flag_verbose) self.oa.add_object(a, flag_verbose = self.flag_verbose) self.oa.add_object(b, flag_verbose = self.flag_verbose) self.oa.add_object(c, flag_verbose = self.flag_verbose)
def test_add_object_with_same_obj_id(self): """ Add object with same obj_id """ a = OA.testobject("Boot", "a", "power", flag_verbose = self.flag_verbose) DEBUG.verbose("\nError is intentional", True) result = self.oa.add_object(a, flag_verbose = self.flag_verbose) self.assertTrue(["a", "b", "c"] == self.oa.obj_id_array and result == False)
def test_obj_id_str(self): oa = OA.objectarray("test") a = OA.testobject("Auto", "a", "power", flag_verbose = self.flag_verbose) oa.add_object(a, flag_verbose = self.flag_verbose) DEBUG.verbose("\nOverwrite warning is intentional", True) oa.save_objectarray(self.path_and_filename, flag_overwrite = True, flag_verbose = self.flag_verbose)
def test_obj_id_unicode(self): """ This testcase may be unnecesary. If you use from __future__ import unicode_literals, then somes strings are suddenly unicode, giving problems when saving the database. However, in Python 3.3 they removed this. Without the __future__ thingy it also works fine in Python 2.7. """ oa = OA.objectarray("test") l = ["auto"] a = OA.testobject(l[0], "a", "power", flag_verbose = self.flag_verbose) oa.add_object(a, flag_verbose = self.flag_verbose) DEBUG.verbose("\nOverwrite warning is intentional", True) oa.save_objectarray(self.path_and_filename, flag_overwrite = True, flag_verbose = self.flag_verbose)
def setUp(self): """ Set up a pickle for use in this function. """ self.path_and_filename = "/Users/robbert/Developer/PythonTools/temp/test.pickle" self.flag_verbose = args.verbose oa = OA.objectarray("test") a = OA.testobject("Auto", "a", "power", flag_verbose = self.flag_verbose) b = OA.testobject("Boot", "b", "power", flag_verbose = self.flag_verbose) c = OA.testobject("Fiets", "c", "human", flag_verbose = self.flag_verbose) oa.add_object(a, flag_verbose = self.flag_verbose) oa.add_object(b, flag_verbose = self.flag_verbose) oa.add_object(c, flag_verbose = self.flag_verbose) DEBUG.verbose("\nOverwrite warning is intentional", True) oa.save_objectarray(self.path_and_filename, flag_overwrite = True, flag_verbose = self.flag_verbose) self.obj_id_array = oa.obj_id_array