示例#1
0
 def setUpClass(cls):
     """
     Import example database.
     """
     cls.db = import_as_dict(EXAMPLE, User())
示例#2
0
    """
    Dynamically generate tests and attach to DatabaseCheck.
    """
    struct = obj.to_struct()
    serialized = obj.__class__.from_struct(struct)
    def test(self):
        self.assertEqual(obj.to_struct(), struct)
    name = "test_serialize_%s_%s" % (obj.__class__.__name__, obj.handle)
    setattr(DatabaseCheck, name, test)
    ####
    #def test2(self):
    #    self.assertEqual(obj.to_struct(), from_struct(struct).to_struct())
    #name = "test_create_%s_%s" % (obj.__class__.__name__, obj.handle)
    #setattr(DatabaseCheck, name, test2)

db = import_as_dict(EXAMPLE, User())
for table in db.get_table_func():
    for handle in db.get_table_func(table,"handles_func")():
        obj = db.get_table_func(table,"handle_func")(handle)
        generate_case(obj)

class StructTest(unittest.TestCase):
    def test(self):
        family = db.get_family_from_gid("F0001")
        s = Struct(family.to_struct(), db)
        self.assertEqual(s["gid"], "F0001")
        s["gid"] = "TEST"
        self.assertEqual(s["gid"], "TEST")
        self.assertEqual(s.father_handle.primary_name.first_name,
                         "Allen Carl")
        s["father_handle.primary_name.first_name"] = "Edward"