From dcea49c2a7d32edb3609f9c3824eda0771c27681 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 2 Jan 2015 17:28:38 -0500 Subject: [PATCH] Updates for struct to pass unit tests --- gramps/gen/lib/test/struct_test.py | 6 +++--- gramps/gen/merge/diff.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gramps/gen/lib/test/struct_test.py b/gramps/gen/lib/test/struct_test.py index d73a779ab..2546601c5 100644 --- a/gramps/gen/lib/test/struct_test.py +++ b/gramps/gen/lib/test/struct_test.py @@ -91,7 +91,7 @@ class TagCheck(unittest.TestCase, BaseCheck): class DatabaseCheck(unittest.TestCase): maxDiff = None -def generate_test(obj): +def generate_case(obj): """ Dynamically generate tests and attach to DatabaseCheck. """ @@ -111,7 +111,7 @@ db = import_as_dict("example/gramps/example.gramps", User()) for table in db._tables.keys(): for handle in db._tables[table]["handles_func"](): obj = db._tables[table]["handle_func"](handle) - generate_test(obj) + generate_case(obj) class StructTest(unittest.TestCase): def test(self): @@ -120,7 +120,7 @@ class StructTest(unittest.TestCase): self.assertEqual(s["gramps_id"], "F0001") s["gramps_id"] = "TEST" self.assertEqual(s["gramps_id"], "TEST") - self.assertEqual(s["father_handle.primary_name.first_name"], + self.assertEqual(s.father_handle.primary_name.first_name, "Allen Carl") s["father_handle.primary_name.first_name"] = "Edward" self.assertEqual(s["father_handle.primary_name.first_name"], diff --git a/gramps/gen/merge/diff.py b/gramps/gen/merge/diff.py index 80a6f3309..67539a0bb 100644 --- a/gramps/gen/merge/diff.py +++ b/gramps/gen/merge/diff.py @@ -384,6 +384,9 @@ class Struct(object): else: self.transaction = None + def __setitem__(self, item, value): + self.struct[item] = value + def __eq__(self, other): if isinstance(other, Struct): return self.struct == other.struct