Ejemplo n.º 1
0
def write_mendeley_papers_to_database(documents):
    '''This function will take a document list and update the Publication model in the database.
    
    To call this you have to get a document list, for example from get_mendeley_authored_documents() 
    the output of that function is then passed to this function.'''
    for key in documents.keys():
        document_dict = {
            'mendeley_url': documents[key]['mendeley_url'],
            'title': documents[key]['title'],
            'journal': documents[key]['published_in'],
            'id': documents[key]['id'],
            'doi': documents[key]['doi'],
            'pmid': documents[key]['pmid'],
            'issn': documents[key]['issn'],
            'year': documents[key]['year'],
            'volume': documents[key]['volume'],
            'issue': documents[key]['issue'],
            'pages': documents[key]['pages'],
            'abstract': documents[key]['abstract'],
            'type': documents[key]['type']
        }
        paper = Publication(document_dict)
        paper.save()
        for author in documents[key]['authors']:
            paper.author_set.add('first_name' =author['forename'],
                                 'last_name' =[author]['surname'])
Ejemplo n.º 2
0
 def test_paper_title_slug(self):
     '''This tests the title_slug field of a :class:`~papers.models.Publication`.'''
     test_publication = Publication(title='Test Publication.',
                                    laboratory_paper=True,
                                    interesting_paper=False,
                                    preprint=False)
     test_publication.save()
     self.assertEqual(test_publication.title_slug, "test-publication")
Ejemplo n.º 3
0
 def test_create_new_paper_minimum(self):
     '''This test creates a :class:`~papers.models.Publication` with the required information only.'''
     test_publication = Publication(title='Test Publication.',
                                    laboratory_paper=True,
                                    interesting_paper=False,
                                    preprint=False)
     test_publication.save()
     self.assertEqual(test_publication.pk, 3)
Ejemplo n.º 4
0
 def test_full_pmcid(self):
     '''This tests that a correct full PMCID can be generated for a :class:`~papers.models.Publication`.'''
     test_publication = Publication(title="Test Publication",
                                    pmcid="12345",
                                    laboratory_paper=True,
                                    interesting_paper=False,
                                    preprint=False)
     test_publication.save()
     self.assertEqual(test_publication.full_pmcid(), 'PMC12345')
Ejemplo n.º 5
0
def write_mendeley_papers_to_database(documents):
    '''This function will take a document list and update the Publication model in the database.
    
    To call this you have to get a document list, for example from get_mendeley_authored_documents() 
    the output of that function is then passed to this function.'''
    for key in documents.keys():
        document_dict = {'mendeley_url' : documents[key]['mendeley_url'],    
        	'title' : documents[key]['title'], 
        	'journal' : documents[key]['published_in'], 
        	'id' : documents[key]['id'],
        	'doi' : documents[key]['doi'],
        	'pmid' : documents[key]['pmid'],
        	'issn' : documents[key]['issn'],  
        	'year' : documents[key]['year'],
        	'volume' : documents[key]['volume'],
            'issue' : documents[key]['issue'], 
            'pages' : documents[key]['pages'],
            'abstract' : documents[key]['abstract'],
            'type' : documents[key]['type']}
        paper = Publication(document_dict)
        paper.save()
        for author in documents[key]['authors']:
            paper.author_set.add('first_name'=author['forename'], 'last_name'=[author]['surname'])
Ejemplo n.º 6
0
 def test_full_pmcid(self):
     '''This tests that a correct full PMCID can be generated for a :class:`~papers.models.Publication`.'''
     test_publication = Publication(title="Test Publication", pmcid = "12345", laboratory_paper=True, interesting_paper=False, preprint=False)
     test_publication.save()
     self.assertEqual(test_publication.full_pmcid(), 'PMC12345')                         
Ejemplo n.º 7
0
 def test_paper_absolute_url(self):
     '''This tests the title_slug field of a :class:`~papers.models.Publication`.'''
     test_publication = Publication(title='Test Publication', laboratory_paper=True, interesting_paper=False, preprint=False)
     test_publication.save()
     self.assertEqual(test_publication.get_absolute_url(), "/papers/test-publication") 
Ejemplo n.º 8
0
 def test_create_new_paper_minimum(self):
     '''This test creates a :class:`~papers.models.Publication` with the required information only.'''
     test_publication = Publication(title='Test Publication.', laboratory_paper=True, interesting_paper=False, preprint=False)
     test_publication.save()
     self.assertEqual(test_publication.pk, 3)