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)
def test_with_private_source_should_anonymize(self, m_anonymize_source) -> None: source = Source('S0', 'The Source') source.private = True ancestry = Ancestry() ancestry.entities.append(source) anonymize(ancestry, AnonymousCitation(AnonymousSource())) m_anonymize_source.assert_called_once_with(source, ANY)
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_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_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_private(self) -> None: sut = Source(None) self.assertIsNone(sut.private) private = True sut.private = private self.assertEquals(private, sut.private)