示例#1
0
 def test_make_new_source_same_author(self):
     """
     Check we can make a new source with two authors, one existing
     
     This shows how to make a new source, and add authors.
     Also, how to find authors of a source, and sources by an author.
     """
     author1, created = Author.objects.get_or_create(name='West, Richard')
     self.assertFalse(created)
     author2, created = Author.objects.get_or_create(
         name='Einstein, Albert')
     self.assertTrue(created)
     paper = Source(
         journal_name="J Phys Chem",
         pub_year='2015',
         source_title='Awesome',
     )
     paper.save()
     for index, author in enumerate([author1, author2]):
         Authorship.objects.create(source=paper,
                                   author=author,
                                   order=index + 1)
     self.assertEqual(
         repr(paper.authors.all().order_by('authorship__order')),
         repr([author1, author2]))
     self.assertEqual(repr(author2.source_set.all()), repr([paper]))
示例#2
0
 def setUp(self):
     b1 = Source()
     b1.bPrimeID = 'b001'
     b1.save()
     a1 = Author()
     a1.name = 'West, Richard'
     a1.save()
     Authorship.objects.create(source=b1, author=a1, order=1)
示例#3
0
 def setUp(self):
     b1 = Source()
     b1.bPrimeID = 'b001'
     b1.save()
     a1 = Author()
     a1.name = 'West, Richard'
     a1.save()
     Authorship.objects.create(source=b1, author=a1, order=1)
示例#4
0
 def test_make_new_source_same_author(self):
     """
     Check we can make a new source with two authors, one existing
     
     This shows how to make a new source, and add authors.
     Also, how to find authors of a source, and sources by an author.
     """
     author1, created = Author.objects.get_or_create(name='West, Richard')
     self.assertFalse(created)
     author2, created = Author.objects.get_or_create(name='Einstein, Albert')
     self.assertTrue(created)
     paper = Source(journal_name="J Phys Chem",
                    pub_year='2015',
                    source_title='Awesome',
                    )
     paper.save()
     for index, author in enumerate([author1, author2]):
         Authorship.objects.create(source=paper, author=author, order=index + 1)
     self.assertEqual(repr(paper.authors.all().order_by('authorship__order')),
                     repr([author1, author2])
                     )
     self.assertEqual(repr(author2.source_set.all()),
                      repr([paper])
                      )