Beispiel #1
0
    def test_clean_should_not_clean_event_with_presences_with_people(
            self) -> None:
        ancestry = Ancestry()

        source = Source('S1', 'The Source')
        ancestry.entities.append(source)

        citation = Citation('C1', source)
        ancestry.entities.append(citation)

        file = File('F1', __file__)
        ancestry.entities.append(file)

        place = Place('P0', [PlaceName('The Place')])
        ancestry.entities.append(place)

        person = Person('P0')

        event = Event('E0', Birth())
        event.citations.append(citation)
        event.files.append(file)
        event.place = place
        ancestry.entities.append(event)

        Presence(person, Subject(), event)

        clean(ancestry)

        self.assertEqual(event, ancestry.entities[Event][event.id])
        self.assertIn(event, place.events)
        self.assertEqual(place, ancestry.entities[Place][place.id])
        self.assertIn(event, citation.facts)
        self.assertEqual(citation, ancestry.entities[Citation][citation.id])
        self.assertIn(event, file.entities)
        self.assertEqual(file, ancestry.entities[File][file.id])
Beispiel #2
0
    def test_clean_should_clean_event(self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S1', 'The Source')
        ancestry.sources[source.id] = source

        citation = IdentifiableCitation('C1', source)
        ancestry.citations[citation.id] = citation

        file = File('F1', __file__)
        ancestry.files[file.id] = file

        place = Place('P0', [PlaceName('The Place')])
        ancestry.places[place.id] = place

        event = IdentifiableEvent('E0', Birth())
        event.citations.append(citation)
        event.files.append(file)
        event.place = place
        ancestry.events[event.id] = event

        clean(ancestry)

        self.assertNotIn(event.id, ancestry.events)
        self.assertIsNone(event.place)
        self.assertNotIn(event, place.events)
        self.assertNotIn(place.id, ancestry.places)
        self.assertNotIn(event, citation.facts)
        self.assertNotIn(citation.id, ancestry.citations)
        self.assertNotIn(event, file.resources)
        self.assertNotIn(file.id, ancestry.files)
Beispiel #3
0
    def test_clean(self) -> None:
        ancestry = Ancestry()

        onymous_event = Event('E0', Birth())
        Presence(Person('P0'), Subject(), onymous_event)
        ancestry.entities.append(onymous_event)

        anonymous_event = Event('E1', Birth())
        ancestry.entities.append(anonymous_event)

        onymous_place = Place('P0', [PlaceName('Amsterdam')])
        onymous_place.events.append(onymous_event)
        ancestry.entities.append(onymous_place)

        anonymous_place = Place('P1', [PlaceName('Almelo')])
        ancestry.entities.append(anonymous_place)

        onmyous_place_because_encloses_onmyous_places = Place(
            'P3', [PlaceName('Netherlands')])
        Enclosure(onymous_place, onmyous_place_because_encloses_onmyous_places)
        Enclosure(anonymous_place,
                  onmyous_place_because_encloses_onmyous_places)
        ancestry.entities.append(onmyous_place_because_encloses_onmyous_places)

        clean(ancestry)

        self.assertEquals([onymous_event], list(ancestry.entities[Event]))
        self.assertEquals(
            [onymous_place, onmyous_place_because_encloses_onmyous_places],
            list(ancestry.entities[Place]))

        self.assertNotIn(
            anonymous_place,
            onmyous_place_because_encloses_onmyous_places.encloses)
Beispiel #4
0
    def test_clean_should_clean_event(self) -> None:
        ancestry = Ancestry()

        source = Source('S1', 'The Source')
        ancestry.entities.append(source)

        citation = Citation('C1', source)
        ancestry.entities.append(citation)

        file = File('F1', __file__)
        ancestry.entities.append(file)

        place = Place('P0', [PlaceName('The Place')])
        ancestry.entities.append(place)

        event = Event('E0', Birth())
        event.citations.append(citation)
        event.files.append(file)
        event.place = place
        ancestry.entities.append(event)

        clean(ancestry)

        self.assertNotIn(event.id, ancestry.entities[Event])
        self.assertIsNone(event.place)
        self.assertNotIn(event, place.events)
        self.assertNotIn(place.id, ancestry.entities[Place])
        self.assertNotIn(event, citation.facts)
        self.assertNotIn(citation.id, ancestry.entities[Citation])
        self.assertNotIn(event, file.entities)
        self.assertNotIn(file.id, ancestry.entities[File])
Beispiel #5
0
    def test_clean_should_not_clean_event_with_presences_with_people(
            self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S1', 'The Source')
        ancestry.sources[source.id] = source

        citation = IdentifiableCitation('C1', source)
        ancestry.citations[citation.id] = citation

        file = File('F1', __file__)
        ancestry.files[file.id] = file

        place = Place('P0', [PlaceName('The Place')])
        ancestry.places[place.id] = place

        person = Person('P0')

        event = IdentifiableEvent('E0', Birth())
        event.citations.append(citation)
        event.files.append(file)
        event.place = place
        ancestry.events[event.id] = event

        Presence(person, Subject(), event)

        clean(ancestry)

        self.assertEqual(event, ancestry.events[event.id])
        self.assertIn(event, place.events)
        self.assertEqual(place, ancestry.places[place.id])
        self.assertIn(event, citation.facts)
        self.assertEqual(citation, ancestry.citations[citation.id])
        self.assertIn(event, file.resources)
        self.assertEqual(file, ancestry.files[file.id])
Beispiel #6
0
    def test_clean_should_clean_source(self) -> None:
        ancestry = Ancestry()

        source = Source('S0', 'The source')
        ancestry.entities.append(source)

        clean(ancestry)

        self.assertNotIn(source.id, ancestry.entities[Source])
Beispiel #7
0
    def test_clean_should_clean_file(self) -> None:
        ancestry = Ancestry()

        file = File('F0', __file__)
        ancestry.files[file.id] = file

        clean(ancestry)

        self.assertNotIn(file.id, ancestry.files)
Beispiel #8
0
    def test_clean_should_clean_source(self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S0', 'The source')
        ancestry.sources[source.id] = source

        clean(ancestry)

        self.assertNotIn(source.id, ancestry.sources)
Beispiel #9
0
    def test_clean_should_clean_file(self) -> None:
        ancestry = Ancestry()

        file = File('F0', __file__)
        ancestry.entities.append(file)

        clean(ancestry)

        self.assertNotIn(file.id, ancestry.entities[File])
Beispiel #10
0
    def test_clean_should_not_clean_person_if_public(self):
        ancestry = Ancestry()

        person = Person('P0')
        person.private = False
        ancestry.people[person.id] = person

        clean(ancestry)

        self.assertEqual(person, ancestry.people[person.id])
Beispiel #11
0
    def test_clean_should_not_clean_person_if_public(self):
        ancestry = Ancestry()

        person = Person('P0')
        person.private = False
        ancestry.entities.append(person)

        clean(ancestry)

        self.assertEqual(person, ancestry.entities[Person][person.id])
Beispiel #12
0
    def test_clean_should_clean_citation(self) -> None:
        ancestry = Ancestry()

        source = Source('S0', 'The source')
        ancestry.entities.append(source)

        citation = Citation('C0', source)
        ancestry.entities.append(citation)

        clean(ancestry)

        self.assertNotIn(citation.id, ancestry.entities[Citation])
        self.assertNotIn(citation, source.citations)
Beispiel #13
0
    def test_clean_should_clean_citation(self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S0', 'The source')
        ancestry.sources[source.id] = source

        citation = IdentifiableCitation('C0', source)
        ancestry.citations[citation.id] = citation

        clean(ancestry)

        self.assertNotIn(citation.id, ancestry.citations)
        self.assertNotIn(citation, source.citations)
Beispiel #14
0
    def test_clean_should_not_clean_source_with_files(self) -> None:
        ancestry = Ancestry()

        file = File('F0', __file__)
        ancestry.files[file.id] = file

        source = IdentifiableSource('S0', 'The Source')
        source.files.append(file)
        ancestry.sources[source.id] = source

        clean(ancestry)

        self.assertEqual(source, ancestry.sources[source.id])
        self.assertIn(source, file.resources)
        self.assertEqual(file, ancestry.files[file.id])
Beispiel #15
0
    def test_clean_should_not_clean_source_with_citations(self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S0', 'The Source')
        ancestry.sources[source.id] = source

        citation = IdentifiableCitation('C0', source)
        citation.facts.append(PersonName('Jane'))
        ancestry.citations[citation.id] = citation

        clean(ancestry)

        self.assertEqual(source, ancestry.sources[source.id])
        self.assertEqual(source, citation.source)
        self.assertEqual(citation, ancestry.citations[citation.id])
Beispiel #16
0
    def test_clean_should_not_clean_source_with_contains(self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S0', 'The Source')
        ancestry.sources[source.id] = source

        contains = IdentifiableSource('S1', 'The Source')
        contains.contained_by = source
        ancestry.sources[contains.id] = contains

        clean(ancestry)

        self.assertEqual(source, ancestry.sources[source.id])
        self.assertEqual(source, contains.contained_by)
        self.assertEqual(contains, ancestry.sources[contains.id])
Beispiel #17
0
    def test_clean_should_not_clean_source_with_citations(self) -> None:
        ancestry = Ancestry()

        source = Source('S0', 'The Source')
        ancestry.entities.append(source)

        citation = Citation('C0', source)
        citation.facts.append(PersonName(Person(None), 'Jane'))
        ancestry.entities.append(citation)

        clean(ancestry)

        self.assertEqual(source, ancestry.entities[Source][source.id])
        self.assertEqual(source, citation.source)
        self.assertEqual(citation, ancestry.entities[Citation][citation.id])
Beispiel #18
0
    def test_clean_should_not_clean_file_with_entities(self) -> None:
        ancestry = Ancestry()

        person = Person('P0')
        ancestry.entities.append(person)

        file = File('F0', __file__)
        file.entities.append(person)
        ancestry.entities.append(file)

        clean(ancestry)

        self.assertEqual(file, ancestry.entities[File][file.id])
        self.assertIn(person, file.entities)
        self.assertEqual(person, ancestry.entities[Person][person.id])
Beispiel #19
0
    def test_clean_should_not_clean_file_with_resources(self) -> None:
        ancestry = Ancestry()

        person = Person('P0')
        ancestry.people[person.id] = person

        file = File('F0', __file__)
        file.resources.append(person)
        ancestry.files[file.id] = file

        clean(ancestry)

        self.assertEqual(file, ancestry.files[file.id])
        self.assertIn(person, file.resources)
        self.assertEqual(person, ancestry.people[person.id])
Beispiel #20
0
    def test_clean_should_not_clean_source_with_contains(self) -> None:
        ancestry = Ancestry()

        source = Source('S0', 'The Source')
        ancestry.entities.append(source)

        contains = Source('S1', 'The Source')
        contains.contained_by = source
        ancestry.entities.append(contains)

        clean(ancestry)

        self.assertEqual(source, ancestry.entities[Source][source.id])
        self.assertEqual(source, contains.contained_by)
        self.assertEqual(contains, ancestry.entities[Source][contains.id])
Beispiel #21
0
    def test_clean_should_not_clean_source_with_files(self) -> None:
        ancestry = Ancestry()

        file = File('F0', __file__)
        ancestry.entities.append(file)

        source = Source('S0', 'The Source')
        source.files.append(file)
        ancestry.entities.append(source)

        clean(ancestry)

        self.assertEqual(source, ancestry.entities[Source][source.id])
        self.assertIn(source, file.entities)
        self.assertEqual(file, ancestry.entities[File][file.id])
Beispiel #22
0
    def test_clean_should_not_clean_file_with_citations(self) -> None:
        ancestry = Ancestry()

        source = Source()

        citation = IdentifiableCitation('C1', source)
        ancestry.citations[citation.id] = citation

        file = File('F0', __file__)
        file.citations.append(citation)
        ancestry.files[file.id] = file

        clean(ancestry)

        self.assertEqual(file, ancestry.files[file.id])
        self.assertIn(citation, file.citations)
        self.assertEqual(citation, ancestry.citations[citation.id])
Beispiel #23
0
    def test_clean_should_not_clean_file_with_citations(self) -> None:
        ancestry = Ancestry()

        source = Source(None)

        citation = Citation('C1', source)
        ancestry.entities.append(citation)

        file = File('F0', __file__)
        file.citations.append(citation)
        ancestry.entities.append(file)

        clean(ancestry)

        self.assertEqual(file, ancestry.entities[File][file.id])
        self.assertIn(citation, file.citations)
        self.assertEqual(citation, ancestry.entities[Citation][citation.id])
Beispiel #24
0
    def test_clean_should_clean_person_with_private_children(self) -> None:
        ancestry = Ancestry()

        person = Person('P0')
        person.private = True
        ancestry.entities.append(person)
        child = Person('P1')
        child.private = True
        ancestry.entities.append(child)
        grandchild = Person('P2')
        grandchild.private = True
        ancestry.entities.append(grandchild)
        great_grandchild = Person('P3')
        great_grandchild.private = True
        ancestry.entities.append(great_grandchild)

        clean(ancestry)

        self.assertNotIn(person.id, ancestry.entities[Person])
Beispiel #25
0
    def test_clean_should_not_clean_citation_with_files(self) -> None:
        ancestry = Ancestry()

        source = Source('S0', 'The Source')
        ancestry.entities.append(source)

        file = File('F0', __file__)
        ancestry.entities.append(file)

        citation = Citation('C0', source)
        citation.files.append(file)
        ancestry.entities.append(citation)

        clean(ancestry)

        self.assertEqual(citation, ancestry.entities[Citation][citation.id])
        self.assertEqual(file, ancestry.entities[File][file.id])
        self.assertIn(citation, source.citations)
        self.assertEqual(source, ancestry.entities[Source][source.id])
Beispiel #26
0
    def test_clean_should_not_clean_citation_with_facts(self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S0', 'The Source')
        ancestry.sources[source.id] = source

        citation = IdentifiableCitation('C0', source)
        citation.facts.append(PersonName('Jane'))
        ancestry.citations[citation.id] = citation

        fact = Person('P0')
        fact.citations.append(citation)
        ancestry.people[fact.id] = fact

        clean(ancestry)

        self.assertEqual(citation, ancestry.citations[citation.id])
        self.assertIn(citation, fact.citations)
        self.assertEqual(fact, ancestry.people[fact.id])
Beispiel #27
0
    def test_clean_should_not_clean_citation_with_files(self) -> None:
        ancestry = Ancestry()

        source = IdentifiableSource('S0', 'The Source')
        ancestry.sources[source.id] = source

        file = File('F0', __file__)
        ancestry.files[file.id] = file

        citation = IdentifiableCitation('C0', source)
        citation.files.append(file)
        ancestry.citations[citation.id] = citation

        clean(ancestry)

        self.assertEqual(citation, ancestry.citations[citation.id])
        self.assertEqual(file, ancestry.files[file.id])
        self.assertIn(citation, source.citations)
        self.assertEqual(source, ancestry.sources[source.id])
Beispiel #28
0
    def test_clean_should_not_clean_person_with_public_children(self):
        ancestry = Ancestry()

        person = Person('P0')
        person.private = False
        ancestry.entities.append(person)
        child = Person('P1')
        child.private = True
        ancestry.entities.append(child)
        grandchild = Person('P2')
        grandchild.private = True
        ancestry.entities.append(grandchild)
        great_grandchild = Person('P3')
        great_grandchild.private = False
        ancestry.entities.append(great_grandchild)

        clean(ancestry)

        self.assertEqual(person, ancestry.entities[Person][person.id])
Beispiel #29
0
    def test_clean_should_clean_person_with_private_children(self) -> None:
        ancestry = Ancestry()

        person = Person('P0')
        person.private = True
        ancestry.people[person.id] = person
        child = Person('P1')
        child.private = True
        ancestry.people[child.id] = child
        grandchild = Person('P2')
        grandchild.private = True
        ancestry.people[grandchild.id] = grandchild
        great_grandchild = Person('P3')
        great_grandchild.private = True
        ancestry.people[great_grandchild.id] = great_grandchild

        clean(ancestry)

        self.assertNotIn(person.id, ancestry.people)
Beispiel #30
0
    def test_clean_should_not_clean_person_with_public_children(self):
        ancestry = Ancestry()

        person = Person('P0')
        person.private = False
        ancestry.people[person.id] = person
        child = Person('P1')
        child.private = True
        ancestry.people[child.id] = child
        grandchild = Person('P2')
        grandchild.private = True
        ancestry.people[grandchild.id] = grandchild
        great_grandchild = Person('P3')
        great_grandchild.private = False
        ancestry.people[great_grandchild.id] = great_grandchild

        clean(ancestry)

        self.assertEqual(person, ancestry.people[person.id])