Bug 9448: Merge unit test for PlaceCheck not working correctly

This commit is contained in:
prculley 2016-05-11 10:18:27 -05:00
parent 9424539930
commit c7914367b7

32
gramps/gen/lib/test/merge_test.py Normal file → Executable file
View File

@ -1389,8 +1389,14 @@ class PlaceCheck(unittest.TestCase, PrivacyBaseTest, MediaBaseTest,
def setUp(self): def setUp(self):
self.phoenix = Place() self.phoenix = Place()
self.phoenix.set_title('Place 1') self.phoenix.set_title('Place 1')
self.titanic = Place(self.phoenix) # __init__ copy has bad side effects, don't use it
self.ref_obj = Place(self.phoenix) # self.titanic = Place(self.phoenix)
self.titanic = Place()
self.titanic.set_title('Place 1')
# __init__ copy has bad side effects, don't use it
# self.ref_obj = Place(self.phoenix)
self.ref_obj = Place()
self.ref_obj.set_title('Place 1')
self.amsterdam = PlaceName() self.amsterdam = PlaceName()
self.amsterdam.set_value('Amsterdam') self.amsterdam.set_value('Amsterdam')
self.rotterdam = PlaceName() self.rotterdam = PlaceName()
@ -1433,9 +1439,11 @@ class PlaceCheck(unittest.TestCase, PrivacyBaseTest, MediaBaseTest,
self.titanic.add_alternative_name(self.leiden) self.titanic.add_alternative_name(self.leiden)
self.ref_obj.set_name(self.amsterdam) self.ref_obj.set_name(self.amsterdam)
self.ref_obj.set_type(PlaceType.CITY) self.ref_obj.set_type(PlaceType.CITY)
self.ref_obj.add_alternative_name(self.amsterdam) # Base name shouldn't be in alt_names list
self.ref_obj.add_alternative_name(self.rotterdam) # self.ref_obj.add_alternative_name(self.amsterdam)
# alt_names must be in correct order for test to pass
self.ref_obj.add_alternative_name(self.utrecht) self.ref_obj.add_alternative_name(self.utrecht)
self.ref_obj.add_alternative_name(self.rotterdam)
self.ref_obj.add_alternative_name(self.leiden) self.ref_obj.add_alternative_name(self.leiden)
self.phoenix.merge(self.titanic) self.phoenix.merge(self.titanic)
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize()) self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
@ -1495,6 +1503,22 @@ class PlaceCheck(unittest.TestCase, PrivacyBaseTest, MediaBaseTest,
self.ref_obj.add_alternative_name(self.rotterdam) self.ref_obj.add_alternative_name(self.rotterdam)
self.phoenix.merge(self.titanic) self.phoenix.merge(self.titanic)
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize()) self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
def test_merge_empty(self):
self.phoenix.set_name(self.amsterdam)
self.phoenix.set_type(PlaceType.CITY)
self.phoenix.add_alternative_name(self.rotterdam)
self.titanic.set_title('Place 2')
# titanic gets empty name
self.titanic.set_type(PlaceType.CITY)
self.titanic.add_alternative_name(self.utrecht)
self.titanic.add_alternative_name(PlaceName()) # empty alt_name
self.ref_obj.set_name(self.amsterdam)
self.ref_obj.set_type(PlaceType.CITY)
self.ref_obj.add_alternative_name(self.rotterdam)
self.ref_obj.add_alternative_name(self.utrecht)
self.phoenix.merge(self.titanic)
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
class RepoCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, UrlBaseTest): class RepoCheck(unittest.TestCase, PrivacyBaseTest, NoteBaseTest, UrlBaseTest):
def setUp(self): def setUp(self):