def testShortNameDefault(self): a = Author(1, 1, 'last', initials='init', forename='first', suffix='suffix') self.assertEqual('init last', a.shortName())
def testShortNameNoInitials(self): a = Author(1, 1, 'last', initials='', forename='first second', suffix='suffix') self.assertEqual('fs last', a.shortName())
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
def testShortNameNoFirstOrInitials(self): a = Author(1, 1, 'last', initials='', forename='', suffix='suffix') self.assertEqual('last', a.shortName())
def testFullNameNoSuffix(self): a = Author(1, 1, 'last', initials='init', forename='first', suffix='') self.assertEqual('first last', a.fullName())
def testFullNameNoFirst(self): a = Author(1, 1, 'last', initials='init', forename='', suffix='suffix') self.assertEqual('init last suffix', a.fullName())
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
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)
def testToRepr(self): self.assertEqual('Author<1:1>', repr(Author(1, 1, 'name')))
def testToString(self): self.assertEqual( '1\t1\tlast\t\\N\tfirst\t\n', str(Author(1, 1, 'last', forename='first', suffix='')))
def testFullNameNoFirstOrInitials(self): a = Author(1, 1, 'last', initials='', forename='', suffix='suffix') self.assertEqual('last suffix', a.fullName())
def testAssignSuffix(self): self.sess.add(Author(1, 1, 'last', suffix='test')) self.assertEqual('test', self.sess.query(Author).first().suffix)
def testAssignFirstName(self): self.sess.add(Author(1, 1, 'last', forename='test')) self.assertEqual('test', self.sess.query(Author).first().forename)
def testAssignInitials(self): self.sess.add(Author(1, 1, 'last', initials='test')) self.assertEqual('test', self.sess.query(Author).first().initials)