Beispiel #1
0
 def testShortNameDefault(self):
     a = Author(1,
                1,
                'last',
                initials='init',
                forename='first',
                suffix='suffix')
     self.assertEqual('init last', a.shortName())
Beispiel #2
0
 def testShortNameNoInitials(self):
     a = Author(1,
                1,
                'last',
                initials='',
                forename='first second',
                suffix='suffix')
     self.assertEqual('fs last', a.shortName())
Beispiel #3
0
    def parseAuthor(self, pos, element):
        name, forename, initials, suffix = self.parseAuthorElements(element.getchildren())

        if initials == forename and initials is not None:
            # prune the repetition of initials in the forename
            forename = None

        if name is not None:
            return Author(self.pmid, pos + 1, name, initials, forename, suffix)
        else:
            logger.warning('empty or missing Author/LastName or CollectiveName in %i',
                           self.pmid)
            return None
Beispiel #4
0
 def testShortNameNoFirstOrInitials(self):
     a = Author(1, 1, 'last', initials='', forename='', suffix='suffix')
     self.assertEqual('last', a.shortName())
Beispiel #5
0
 def testShortNameDefault(self):
     a = Author(1, 1, 'last', initials='init', forename='first', suffix='suffix')
     self.assertEqual('init last', a.shortName())
Beispiel #6
0
 def testFullNameNoSuffix(self):
     a = Author(1, 1, 'last', initials='init', forename='first', suffix='')
     self.assertEqual('first last', a.fullName())
Beispiel #7
0
 def testFullNameNoFirst(self):
     a = Author(1, 1, 'last', initials='init', forename='', suffix='suffix')
     self.assertEqual('init last suffix', a.fullName())
Beispiel #8
0
from collections import defaultdict
from datetime import date
from io import StringIO
from tempfile import TemporaryFile

from medic.orm import Medline, Section, Author, Descriptor, Qualifier, Database, Identifier, \
        Chemical, Keyword, PublicationType
from medic.crud import _dump

DATA = [
    Section(1, 1, 'Title', 'The Title'),
    Section(1, 2, 'Abstract', 'The Abstract'),
    Descriptor(1, 1, 'd_name', True),
    Descriptor(1, 2, 'd_name'),
    Qualifier(1, 1, 1, 'q_name', True),
    Author(1, 1, 'first'),
    Author(1, 2, 'last'),
    Identifier(1, 'ns', 'id'),
    Database(1, 'name', 'accession'),
    PublicationType(1, 'some'),
    PublicationType(1, 'another'),
    Chemical(1, 1, 'name', 'uid'),
    Keyword(1, 'NOTNLM', 1, 'name', True),
    Medline(1, 'MEDLINE', 'journal', 'pub_date', date.today()),
]


class ParserMock:
    def __init__(self, instances):
        self.instances = instances
Beispiel #9
0
 def testRelations(self):
     a = Author(1, 1, 'last')
     self.sess.add(a)
     self.sess.commit()
     self.assertListEqual([a], self.M.authors)
     self.assertEqual(self.M, a.citation)
Beispiel #10
0
 def testToRepr(self):
     self.assertEqual('Author<1:1>', repr(Author(1, 1, 'name')))
Beispiel #11
0
 def testToString(self):
     self.assertEqual(
         '1\t1\tlast\t\\N\tfirst\t\n',
         str(Author(1, 1, 'last', forename='first', suffix='')))
Beispiel #12
0
 def testFullNameNoSuffix(self):
     a = Author(1, 1, 'last', initials='init', forename='first', suffix='')
     self.assertEqual('first last', a.fullName())
Beispiel #13
0
 def testFullNameNoFirstOrInitials(self):
     a = Author(1, 1, 'last', initials='', forename='', suffix='suffix')
     self.assertEqual('last suffix', a.fullName())
Beispiel #14
0
 def testAssignSuffix(self):
     self.sess.add(Author(1, 1, 'last', suffix='test'))
     self.assertEqual('test', self.sess.query(Author).first().suffix)
Beispiel #15
0
 def testAssignFirstName(self):
     self.sess.add(Author(1, 1, 'last', forename='test'))
     self.assertEqual('test', self.sess.query(Author).first().forename)
Beispiel #16
0
 def testAssignInitials(self):
     self.sess.add(Author(1, 1, 'last', initials='test'))
     self.assertEqual('test', self.sess.query(Author).first().initials)