예제 #1
0
 def testShortNameDefault(self):
     a = Author(1,
                1,
                'last',
                initials='init',
                forename='first',
                suffix='suffix')
     self.assertEqual('init last', a.shortName())
예제 #2
0
 def testShortNameNoInitials(self):
     a = Author(1,
                1,
                'last',
                initials='',
                forename='first second',
                suffix='suffix')
     self.assertEqual('fs last', a.shortName())
예제 #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
예제 #4
0
파일: orm_test.py 프로젝트: dsjl4506/medic
 def testShortNameNoFirstOrInitials(self):
     a = Author(1, 1, 'last', initials='', forename='', suffix='suffix')
     self.assertEqual('last', a.shortName())
예제 #5
0
파일: orm_test.py 프로젝트: dsjl4506/medic
 def testShortNameDefault(self):
     a = Author(1, 1, 'last', initials='init', forename='first', suffix='suffix')
     self.assertEqual('init last', a.shortName())
예제 #6
0
파일: orm_test.py 프로젝트: dsjl4506/medic
 def testFullNameNoSuffix(self):
     a = Author(1, 1, 'last', initials='init', forename='first', suffix='')
     self.assertEqual('first last', a.fullName())
예제 #7
0
파일: orm_test.py 프로젝트: dsjl4506/medic
 def testFullNameNoFirst(self):
     a = Author(1, 1, 'last', initials='init', forename='', suffix='suffix')
     self.assertEqual('init last suffix', a.fullName())
예제 #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
예제 #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)
예제 #10
0
 def testToRepr(self):
     self.assertEqual('Author<1:1>', repr(Author(1, 1, 'name')))
예제 #11
0
 def testToString(self):
     self.assertEqual(
         '1\t1\tlast\t\\N\tfirst\t\n',
         str(Author(1, 1, 'last', forename='first', suffix='')))
예제 #12
0
 def testFullNameNoSuffix(self):
     a = Author(1, 1, 'last', initials='init', forename='first', suffix='')
     self.assertEqual('first last', a.fullName())
예제 #13
0
 def testFullNameNoFirstOrInitials(self):
     a = Author(1, 1, 'last', initials='', forename='', suffix='suffix')
     self.assertEqual('last suffix', a.fullName())
예제 #14
0
 def testAssignSuffix(self):
     self.sess.add(Author(1, 1, 'last', suffix='test'))
     self.assertEqual('test', self.sess.query(Author).first().suffix)
예제 #15
0
 def testAssignFirstName(self):
     self.sess.add(Author(1, 1, 'last', forename='test'))
     self.assertEqual('test', self.sess.query(Author).first().forename)
예제 #16
0
 def testAssignInitials(self):
     self.sess.add(Author(1, 1, 'last', initials='test'))
     self.assertEqual('test', self.sess.query(Author).first().initials)