コード例 #1
0
 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)
コード例 #2
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)
コード例 #3
0
 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))
コード例 #4
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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
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)
コード例 #9
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()
コード例 #10
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)
コード例 #11
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)
コード例 #12
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)
コード例 #13
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()
コード例 #14
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)
コード例 #15
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)
コード例 #16
0
 def test_name(self):
     self.assertIsInstance(AnonymousSource().name, str)