def test_with_private_event_should_anonymize(self, m_anonymize_event) -> None: event = Event('E0', Birth()) event.private = True ancestry = Ancestry() ancestry.entities.append(event) anonymize(ancestry, AnonymousCitation(AnonymousSource())) m_anonymize_event.assert_called_once_with(event)
def test_with_public_source_should_not_anonymize( self, m_anonymize_source) -> None: source = Source('S0', 'The Source') source.private = False ancestry = Ancestry() ancestry.entities.append(source) anonymize(ancestry, AnonymousCitation(AnonymousSource())) m_anonymize_source.assert_not_called()
def test_with_private_file_should_anonymize(self, m_anonymize_file) -> None: file = File('F0', __file__) file.private = True ancestry = Ancestry() ancestry.entities.append(file) anonymize(ancestry, AnonymousCitation(AnonymousSource())) m_anonymize_file.assert_called_once_with(file)
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])
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])
def test_with_public_citation_should_not_anonymize( self, m_anonymize_citation) -> None: source = Source('The Source') citation = Citation('C0', source) citation.private = False ancestry = Ancestry() ancestry.entities.append(citation) anonymize(ancestry, AnonymousCitation(AnonymousSource())) m_anonymize_citation.assert_not_called()
def test_with_private_citation_should_anonymize( self, m_anonymize_citation) -> None: source = Source('The Source') citation = Citation('C0', source) citation.private = True ancestry = Ancestry() ancestry.entities.append(citation) anonymize(ancestry, AnonymousCitation(AnonymousSource())) m_anonymize_citation.assert_called_once_with(citation, ANY)
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])
def test_privatize_person_without_relatives(self, expected, private, event: Optional[Event]): person = Person('P0') person.private = private if event is not None: Presence(person, Subject(), event) ancestry = Ancestry() ancestry.entities.append(person) privatize(ancestry) self.assertEquals(expected, person.private)
def test_privatize_source_should_not_privatize_if_public(self): file = File('F0', __file__) source = Source('S0', 'The Source') source.private = False source.files.append(file) ancestry = Ancestry() ancestry.entities.append(source) privatize(ancestry) self.assertEqual(False, source.private) self.assertIsNone(file.private)
def test_privatize_source_should_privatize_if_private(self): file = File('F0', __file__) source = Source('S0', 'The Source') source.private = True source.files.append(file) ancestry = Ancestry() ancestry.entities.append(source) privatize(ancestry) self.assertTrue(source.private) self.assertTrue(file.private)
def test_privatize_file_should_privatize_if_private(self): source = Source(None, 'The Source') citation = Citation(None, source) file = File('F0', __file__) file.private = True file.citations.append(citation) ancestry = Ancestry() ancestry.entities.append(file) privatize(ancestry) self.assertTrue(True, file.private) self.assertTrue(citation.private)
def test_privatize_file_should_not_privatize_if_public(self): source = Source(None, 'The Source') citation = Citation(None, source) file = File('F0', __file__) file.private = False file.citations.append(citation) ancestry = Ancestry() ancestry.entities.append(file) privatize(ancestry) self.assertEqual(False, file.private) self.assertIsNone(citation.private)
def test_privatize_person_with_child(self, expected, private, event: Optional[Event]): person = Person('P0') person.private = private child = Person('P1') if event is not None: Presence(child, Subject(), event) person.children.append(child) ancestry = Ancestry() ancestry.entities.append(person) privatize(ancestry) self.assertEquals(expected, person.private)
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)
def test_privatize_person_with_grandparent(self, expected, private, event: Optional[Event]): person = Person('P0') person.private = private parent = Person('P1') person.parents.append(parent) grandparent = Person('P2') if event is not None: Presence(grandparent, Subject(), event) parent.parents.append(grandparent) ancestry = Ancestry() ancestry.entities.append(person) privatize(ancestry) self.assertEquals(expected, person.private)
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])
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])
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])
def test_privatize_citation_should_privatize_if_private(self): source_file = File('F0', __file__) source = Source('The Source') source.files.append(source_file) citation_file = File('F1', __file__) citation = Citation('C0', source) citation.private = True citation.files.append(citation_file) ancestry = Ancestry() ancestry.entities.append(citation) privatize(ancestry) self.assertTrue(citation.private) self.assertTrue(source.private) self.assertTrue(citation_file.private) self.assertTrue(source_file.private)
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])
def test_privatize_citation_should_not_privatize_if_public(self): source_file = File('F0', __file__) source = Source('The Source') source.files.append(source_file) citation_file = File('F1', __file__) citation = Citation('C0', source) citation.private = False citation.files.append(citation_file) ancestry = Ancestry() ancestry.entities.append(citation) privatize(ancestry) self.assertEqual(False, citation.private) self.assertIsNone(source.private) self.assertIsNone(citation_file.private) self.assertIsNone(source_file.private)
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])
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])
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])
def test_clean_should_not_clean_citation_with_facts(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) fact = Person('P0') fact.citations.append(citation) ancestry.entities.append(fact) clean(ancestry) self.assertEqual(citation, ancestry.entities[Citation][citation.id]) self.assertIn(citation, fact.citations) self.assertEqual(fact, ancestry.entities[Person][fact.id])
def __init__(self, configuration: Configuration): self._active = False self._ancestry = Ancestry() self._configuration = configuration self._assets = FileSystem() self._dispatcher = None self._localized_url_generator = AppUrlGenerator(configuration) self._static_url_generator = StaticPathUrlGenerator(configuration) self._debug = None self._locale = None self._translations = defaultdict(gettext.NullTranslations) self._default_translations = None self._extensions = None self._activation_exit_stack = AsyncExitStack() self._jinja2_environment = None self._renderer = None self._executor = None self._locks = Locks() self._http_client = None
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])
def test_privatize_event_should_privatize_if_private(self): source_file = File('F0', __file__) source = Source('The Source') source.files.append(source_file) citation_file = File('F1', __file__) citation = Citation('C0', source) citation.files.append(citation_file) event_file = File('F1', __file__) event = Event('E1', Birth()) event.private = True event.citations.append(citation) event.files.append(event_file) person = Person('P0') Presence(person, Subject(), event) ancestry = Ancestry() ancestry.entities.append(event) privatize(ancestry) self.assertTrue(event.private) self.assertTrue(event_file.private) self.assertTrue(citation.private) self.assertTrue(source.private) self.assertTrue(citation_file.private) self.assertTrue(source_file.private) self.assertIsNone(person.private)