def test_should_remove_source(self) -> None: source = Source('The Source') citation = Citation('C0', source) anonymous_source = AnonymousSource() anonymous_citation = AnonymousCitation(anonymous_source) anonymize_citation(citation, anonymous_citation) self.assertIsNone(citation.source)
def test_with_private_person_should_anonymize(self, m_anonymize_person) -> None: person = Person('P0') person.private = True ancestry = Ancestry() ancestry.entities.append(person) anonymize(ancestry, AnonymousCitation(AnonymousSource())) m_anonymize_person.assert_called_once_with(person)
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_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_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_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_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_replace(self): facts = [HasCitations()] files = [File('F1', __file__)] source = Mock(Source) sut = AnonymousCitation(source) other = AnonymousCitation(source) other.facts = facts other.files = files sut.replace(other) self.assertEquals(facts, list(sut.facts)) self.assertEquals(files, list(sut.files))
def test_should_remove_files(self) -> None: source = Source('The Source') citation = Citation('C0', source) file = File('F0', __file__) citation.files.append(file) anonymous_source = AnonymousSource() anonymous_citation = AnonymousCitation(anonymous_source) anonymize_citation(citation, anonymous_citation) self.assertEquals(0, len(citation.files)) self.assertIn(file, anonymous_citation.files)
def test_should_remove_facts(self) -> None: source = Source('The Source') citation = Citation('C0', source) fact = PersonName(Person(None), 'Jane') citation.facts.append(fact) anonymous_source = AnonymousSource() anonymous_citation = AnonymousCitation(anonymous_source) anonymize_citation(citation, anonymous_citation) self.assertEquals(0, len(citation.facts)) self.assertIn(fact, anonymous_citation.facts)
def test_location(self): source = Mock(Source) self.assertIsInstance(AnonymousCitation(source).location, str)