def test_should_remove_contained_by(self) -> None: source = Source('S0', 'The Source') contained_by = Source(None, 'The Source') source.contained_by = contained_by anonymous_source = AnonymousSource() anonymize_source(source, anonymous_source) self.assertIsNone(source.contained_by)
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_replace(self): citations = [Citation(None, Source(None))] contains = [Source(None)] files = [Mock(File)] sut = AnonymousSource() other = AnonymousSource() other.citations = citations other.contains = contains other.files = files sut.replace(other) self.assertEquals(citations, list(sut.citations)) self.assertEquals(contains, list(sut.contains)) self.assertEquals(files, list(sut.files))
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_should_remove_files(self) -> None: source = Source('S0', 'The Source') file = File('F0', __file__) source.files.append(file) anonymous_source = AnonymousSource() anonymize_source(source, anonymous_source) self.assertEquals(0, len(source.files)) self.assertIn(file, anonymous_source.files)
def test_should_remove_contains(self) -> None: source = Source('S0', 'The Source') contains = Source(None, 'The Source') source.contains.append(contains) anonymous_source = AnonymousSource() anonymize_source(source, anonymous_source) self.assertEquals(0, len(source.contains)) self.assertIn(contains, anonymous_source.contains)
def test_should_remove_citations(self) -> None: source = Source('S0', 'The Source') citation = Citation(None, source) source.citations.append(citation) anonymous_source = AnonymousSource() anonymize_source(source, anonymous_source) self.assertEquals(0, len(source.citations)) self.assertIn(citation, anonymous_source.citations)
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_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_name(self): self.assertIsInstance(AnonymousSource().name, str)