7650: New unit tests for merging places
This commit is contained in:
parent
27dab7c811
commit
afd154a19e
@ -28,7 +28,7 @@ from .. import (Person, Surname, Name, NameType, Family, FamilyRelType,
|
||||
StyledText, StyledTextTag, StyledTextTagType, Tag,
|
||||
ChildRef, ChildRefType, Attribute, MediaRef, AttributeType,
|
||||
Url, UrlType, Address, EventRef, EventRoleType, RepoRef,
|
||||
FamilyRelType, LdsOrd, MediaRef, PersonRef, Location)
|
||||
FamilyRelType, LdsOrd, MediaRef, PersonRef, PlaceType)
|
||||
from ..privacybase import PrivacyBase
|
||||
from ..urlbase import UrlBase
|
||||
from ..addressbase import AddressBase
|
||||
@ -1388,89 +1388,98 @@ class PlaceCheck(unittest.TestCase, PrivacyBaseTest, MediaBaseTest,
|
||||
self.ref_obj = Place(self.phoenix)
|
||||
|
||||
def test_merge_primary_identical(self):
|
||||
loc = Location()
|
||||
loc.set_city('Amsterdam')
|
||||
self.phoenix.set_main_location(loc)
|
||||
self.phoenix.set_name('Amsterdam')
|
||||
self.phoenix.set_type(PlaceType.CITY)
|
||||
self.titanic.set_title('Place 2')
|
||||
loc2 = Location()
|
||||
loc2.set_city('Amsterdam')
|
||||
self.titanic.set_main_location(loc2)
|
||||
self.ref_obj.set_main_location(loc)
|
||||
self.titanic.set_name('Amsterdam')
|
||||
self.titanic.set_type(PlaceType.CITY)
|
||||
self.ref_obj.set_name('Amsterdam')
|
||||
self.ref_obj.set_type(PlaceType.CITY)
|
||||
self.phoenix.merge(self.titanic)
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
def test_merge_primary_different(self):
|
||||
loc = Location()
|
||||
loc.set_city('Amsterdam')
|
||||
self.phoenix.set_main_location(loc)
|
||||
self.phoenix.set_name('Amsterdam')
|
||||
self.phoenix.set_type(PlaceType.CITY)
|
||||
self.titanic.set_title('Place 2')
|
||||
loc2 = Location()
|
||||
loc2.set_city('Rotterdam')
|
||||
self.titanic.set_main_location(loc2)
|
||||
self.ref_obj.set_main_location(loc)
|
||||
self.ref_obj.add_alternate_locations(loc2)
|
||||
self.titanic.set_name('Rotterdam')
|
||||
self.titanic.set_type(PlaceType.CITY)
|
||||
self.ref_obj.set_name('Amsterdam')
|
||||
self.ref_obj.set_type(PlaceType.CITY)
|
||||
self.ref_obj.add_alternative_name('Rotterdam')
|
||||
self.phoenix.merge(self.titanic)
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
def test_merge_primary_null(self):
|
||||
"""
|
||||
Even if primary location of phoenix is null, still add titanics
|
||||
primary to alternate locations.
|
||||
"""
|
||||
loc = Location()
|
||||
loc.set_city('Amsterdam')
|
||||
self.titanic.set_title('Place2')
|
||||
self.titanic.set_main_location(loc)
|
||||
self.ref_obj.add_alternate_locations(loc)
|
||||
def test_merge_both_different(self):
|
||||
self.phoenix.set_name('Amsterdam')
|
||||
self.phoenix.set_type(PlaceType.CITY)
|
||||
self.phoenix.add_alternative_name('Utrecht')
|
||||
self.titanic.set_title('Place 2')
|
||||
self.titanic.set_name('Rotterdam')
|
||||
self.titanic.set_type(PlaceType.CITY)
|
||||
self.titanic.add_alternative_name('Leiden')
|
||||
self.ref_obj.set_name('Amsterdam')
|
||||
self.ref_obj.set_type(PlaceType.CITY)
|
||||
self.ref_obj.add_alternative_name('Amsterdam')
|
||||
self.ref_obj.add_alternative_name('Rotterdam')
|
||||
self.ref_obj.add_alternative_name('Utrecht')
|
||||
self.ref_obj.add_alternative_name('Leiden')
|
||||
self.phoenix.merge(self.titanic)
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
def test_merge_alternate_identical(self):
|
||||
loc = Location()
|
||||
loc.set_city('Amsterdam')
|
||||
self.phoenix.add_alternate_locations(loc)
|
||||
loc2 = Location()
|
||||
loc2.set_city('Amsterdam')
|
||||
self.titanic.add_alternate_locations(loc2)
|
||||
self.ref_obj.add_alternate_locations(loc)
|
||||
def test_merge_alternative_identical(self):
|
||||
self.phoenix.set_name('Amsterdam')
|
||||
self.phoenix.set_type(PlaceType.CITY)
|
||||
self.phoenix.add_alternative_name('Rotterdam')
|
||||
self.titanic.set_title('Place 2')
|
||||
self.titanic.set_name('Amsterdam')
|
||||
self.titanic.set_type(PlaceType.CITY)
|
||||
self.titanic.add_alternative_name('Rotterdam')
|
||||
self.ref_obj.set_name('Amsterdam')
|
||||
self.ref_obj.set_type(PlaceType.CITY)
|
||||
self.ref_obj.add_alternative_name('Rotterdam')
|
||||
self.phoenix.merge(self.titanic)
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
def test_merge_alternate_different(self):
|
||||
loc = Location()
|
||||
loc.set_city('Amsterdam')
|
||||
self.phoenix.add_alternate_locations(loc)
|
||||
loc2 = Location()
|
||||
loc2.set_city('Rotterdam')
|
||||
self.titanic.add_alternate_locations(loc2)
|
||||
self.ref_obj.add_alternate_locations(loc)
|
||||
self.ref_obj.add_alternate_locations(loc2)
|
||||
def test_merge_alternative_different(self):
|
||||
self.phoenix.set_name('Amsterdam')
|
||||
self.phoenix.set_type(PlaceType.CITY)
|
||||
self.phoenix.add_alternative_name('Rotterdam')
|
||||
self.titanic.set_title('Place 2')
|
||||
self.titanic.set_name('Amsterdam')
|
||||
self.titanic.set_type(PlaceType.CITY)
|
||||
self.titanic.add_alternative_name('Utrecht')
|
||||
self.ref_obj.set_name('Amsterdam')
|
||||
self.ref_obj.set_type(PlaceType.CITY)
|
||||
self.ref_obj.add_alternative_name('Rotterdam')
|
||||
self.ref_obj.add_alternative_name('Utrecht')
|
||||
self.phoenix.merge(self.titanic)
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
def test_merge_prialt_identical(self):
|
||||
loc = Location()
|
||||
loc.set_city('Amsterdam')
|
||||
self.phoenix.set_main_location(loc)
|
||||
loc2 = Location()
|
||||
loc2.set_city('Amsterdam')
|
||||
self.titanic.add_alternate_locations(loc2)
|
||||
self.ref_obj.set_main_location(loc)
|
||||
self.phoenix.set_name('Amsterdam')
|
||||
self.phoenix.set_type(PlaceType.CITY)
|
||||
self.phoenix.add_alternative_name('Rotterdam')
|
||||
self.titanic.set_title('Place 2')
|
||||
self.titanic.set_name('Rotterdam')
|
||||
self.titanic.set_type(PlaceType.CITY)
|
||||
self.ref_obj.set_name('Amsterdam')
|
||||
self.ref_obj.set_type(PlaceType.CITY)
|
||||
self.ref_obj.add_alternative_name('Rotterdam')
|
||||
self.phoenix.merge(self.titanic)
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
def test_merge_prialt2(self):
|
||||
loc = Location()
|
||||
loc.set_city('Amsterdam')
|
||||
self.phoenix.set_main_location(loc)
|
||||
loc2 = Location()
|
||||
loc2.set_city('Rotterdam')
|
||||
loc3 = Location()
|
||||
loc3.set_city('Rotterdam')
|
||||
self.phoenix.add_alternate_locations(loc2)
|
||||
self.titanic.set_main_location(loc3)
|
||||
self.ref_obj.set_main_location(loc)
|
||||
self.ref_obj.add_alternate_locations(loc2)
|
||||
self.phoenix.set_name('Amsterdam')
|
||||
self.phoenix.set_type(PlaceType.CITY)
|
||||
self.phoenix.add_alternative_name('Rotterdam')
|
||||
self.titanic.set_title('Place 2')
|
||||
self.titanic.set_name('Rotterdam')
|
||||
self.titanic.set_type(PlaceType.CITY)
|
||||
self.titanic.add_alternative_name('Amsterdam')
|
||||
self.ref_obj.set_name('Amsterdam')
|
||||
self.ref_obj.set_type(PlaceType.CITY)
|
||||
self.ref_obj.add_alternative_name('Rotterdam')
|
||||
self.phoenix.merge(self.titanic)
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_obj.serialize())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user