class Test_ObjFramework_2_records_same_cls(unittest.TestCase): def setUp(self): self.of = ObjFactory() self.obj1= self.of.new(GenericBase, 'Student', objid='booker', modname=__name__, name='booker', age=23) self.obj2= self.of.new(GenericBase, 'Student', objid='frank', modname=__name__, name='frank', age=19) def tearDown(self): self.of.reset() def test_2records_same_class(self): names = [obj.name for obj in self.of.query('Student')] names.sort() self.assertEquals(names,['booker','frank'])
class Test_ObjFramework_Database(unittest.TestCase): def setUp(self): self.of = ObjFactory(True) self.database = Database('foobar') self.foobar= self.of.new(dbtblgeneric, 'DBLesson', objid='dblesson0', constructor='datamembers', modname=__name__, database=self.database, dm={'student':'booker', 'period':2, 'dow':3}) def tearDown(self): self.of.reset() def test_num_obj_created(self): self.assertEquals(len(self.of.query('DBLesson')),1) def test_correct_keys_created(self): self.assertTrue(self.of.object_exists('DBLesson','dblesson0')) def test_objects_created_stored(self): _lesson = self.of.object_get('DBLesson','dblesson0') self.assertEquals(_lesson.__class__.__name__,"DBLesson") def test_objects_have_attributes(self): _lesson = self.of.object_get('DBLesson','dblesson0') self.assertEquals(_lesson.student,'booker') self.assertEquals(_lesson.period,2) self.assertEquals(_lesson.dow,3)
class Test_ObjFramework_Database_Derived(unittest.TestCase): # pass in a subclass of dbtblgeneric as a baseclass; testing a bug found # in schoolschedulewizard class Dummy(dbtblgeneric): pass def setUp(self): self.of = ObjFactory(True) self.database = Database('foobar') self.foobar= self.of.new(self.Dummy, 'DBLesson', objid='dblesson0', constructor='datamembers', modname=__name__, database=self.database, dm={'student':'booker', 'period':2, 'dow':3}) def test_num_obj_created(self): self.assertEquals(len(self.of.query('DBLesson')),1)
class Test_ObjFramework_2_class(unittest.TestCase): def setUp(self): self.of = ObjFactory() self.obj1= self.of.new(GenericBase, 'Student', objid='booker', modname=__name__, name='booker', age=23) self.obj2= self.of.new(GenericBase, 'Subject', objid='science', modname=__name__, name='science', teacher_name='fran') def tearDown(self): self.of.reset() def test_2_class(self): self.assertListEqual(self.of.query(),['Student','Subject'])