Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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()
Example #5
0
 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)
Example #6
0
 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)
Example #7
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)
Example #8
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()
Example #9
0
 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))
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 def test_location(self):
     source = Mock(Source)
     self.assertIsInstance(AnonymousCitation(source).location, str)