Esempio n. 1
0
    async def test_post_load(self):
        person = Person('P0')
        Presence(person, Subject(), Event(None, Birth()))

        source_file = File('F0', __file__)
        source = Source('S0', 'The Source')
        source.private = True
        source.files.append(source_file)

        citation_file = File('F0', __file__)
        citation_source = Source('The Source')
        citation = Citation('C0', citation_source)
        citation.private = True
        citation.files.append(citation_file)

        with TemporaryDirectory() as output_directory_path:
            configuration = Configuration(output_directory_path,
                                          'https://example.com')
            configuration.extensions.add(ExtensionConfiguration(Privatizer))
            async with App(configuration) as app:
                app.ancestry.entities.append(person)
                app.ancestry.entities.append(source)
                app.ancestry.entities.append(citation)
                await load(app)

            self.assertTrue(person.private)
            self.assertTrue(source_file.private)
            self.assertTrue(citation_file.private)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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()
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 def test_private(self) -> None:
     sut = Citation(None, Mock(Source))
     self.assertIsNone(sut.private)
     private = True
     sut.private = private
     self.assertEquals(private, sut.private)