Example #1
0
 def test_with_private_source_should_anonymize(self,
                                               m_anonymize_source) -> None:
     source = Source('S0', 'The Source')
     source.private = True
     ancestry = Ancestry()
     ancestry.sources[source.id] = source
     anonymize(ancestry)
     m_anonymize_source.assert_called_once_with(source)
Example #2
0
 def test_with_private_file_should_anonymize(self,
                                             m_anonymize_file) -> None:
     file = File('F0', __file__)
     file.private = True
     ancestry = Ancestry()
     ancestry.files[file.id] = file
     anonymize(ancestry)
     m_anonymize_file.assert_called_once_with(file)
Example #3
0
 def test_with_public_source_should_not_anonymize(
         self, m_anonymize_source) -> None:
     source = Source('S0', 'The Source')
     source.private = False
     ancestry = Ancestry()
     ancestry.sources[source.id] = source
     anonymize(ancestry)
     m_anonymize_source.assert_not_called()
Example #4
0
 def test_with_private_event_should_anonymize(self,
                                              m_anonymize_event) -> None:
     event = IdentifiableEvent('E0', Event.Type.BIRTH)
     event.private = True
     ancestry = Ancestry()
     ancestry.events[event.id] = event
     anonymize(ancestry)
     m_anonymize_event.assert_called_once_with(event)
Example #5
0
 def test_with_public_file_should_not_anonymize(self,
                                                m_anonymize_file) -> None:
     file = File('F0', __file__)
     file.private = False
     ancestry = Ancestry()
     ancestry.files[file.id] = file
     anonymize(ancestry)
     m_anonymize_file.assert_not_called()
Example #6
0
 def test_with_private_person_should_anonymize(self,
                                               m_anonymize_person) -> None:
     person = Person('P0')
     person.private = True
     ancestry = Ancestry()
     ancestry.people[person.id] = person
     anonymize(ancestry)
     m_anonymize_person.assert_called_once_with(person)
Example #7
0
 def test_with_public_event_should_not_anonymize(self,
                                                 m_anonymize_event) -> None:
     event = IdentifiableEvent('E0', Event.Type.BIRTH)
     event.private = False
     ancestry = Ancestry()
     ancestry.events[event.id] = event
     anonymize(ancestry)
     m_anonymize_event.assert_not_called()
Example #8
0
 def test_with_public_person_should_not_anonymize(
         self, m_anonymize_person) -> None:
     person = Person('P0')
     person.private = False
     ancestry = Ancestry()
     ancestry.people[person.id] = person
     anonymize(ancestry)
     m_anonymize_person.assert_not_called()
Example #9
0
 def test_with_public_citation_should_not_anonymize(
         self, m_anonymize_citation) -> None:
     source = Source('S0', 'The Source')
     citation = Citation('C0', source)
     citation.private = False
     ancestry = Ancestry()
     ancestry.citations[citation.id] = citation
     anonymize(ancestry)
     m_anonymize_citation.assert_not_called()
Example #10
0
 def test_with_private_citation_should_anonymize(
         self, m_anonymize_citation) -> None:
     source = Source('S0', 'The Source')
     citation = Citation('C0', source)
     citation.private = True
     ancestry = Ancestry()
     ancestry.citations[citation.id] = citation
     anonymize(ancestry)
     m_anonymize_citation.assert_called_once_with(citation)
Example #11
0
 def test_anonymize_should_not_anonymize_public_person(self):
     with NamedTemporaryFile() as file_f:
         person = Person('P0', 'Janet', 'Dough')
         presence = Presence(Presence.Role.SUBJECT)
         presence.event = Event('E0', Event.Type.BIRTH)
         person.presences.add(presence)
         person.files.add(File('D0', file_f.name))
         ancestry = Ancestry()
         ancestry.people[person.id] = person
         anonymize(ancestry)
         self.assert_not_anonymized(person)
Example #12
0
 def test_anonymize_should_anonymize_private_person(self):
     with NamedTemporaryFile() as file_f:
         person = Person('P0', 'Janet', 'Dough')
         person.private = True
         partner = Person('P1', 'Jenny', 'Donut')
         person_presence = Presence(Presence.Role.SUBJECT)
         person_presence.person = person
         partner_presence = Presence(Presence.Role.SUBJECT)
         partner_presence.person = partner
         event = Event('E0', Event.Type.MARRIAGE)
         event.presences = [person_presence, partner_presence]
         file = File('D0', file_f.name)
         file.entities.add(person, partner)
         ancestry = Ancestry()
         ancestry.people[person.id] = person
         anonymize(ancestry)
         self.assert_anonymized(person)
         self.assertCountEqual([], event.presences)
         self.assertCountEqual([], file.entities)
Example #13
0
    def test_anonymize_should_not_anonymize_people_with_public_descendants(
            self):
        ancestry = Ancestry()

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

        anonymize(ancestry)
        self.assertCountEqual([child], person.children)
        self.assertCountEqual([grandchild], child.children)
        self.assertCountEqual([great_grandchild], grandchild.children)