def testEquals(self): self.assertSame() self.assertDifference(cnt=2) self.assertDifference(owner='NLM') self.assertDifference(name='other') self.assertNotEqual(Keyword(1, 'NASA', 1, 'name', True), Keyword(1, 'NASA', 1, 'name', False))
def KeywordList(self, element): owner = element.get('Owner', 'NLM').strip().upper() logger.debug('KeywordList Owner="%s"', owner) for cnt, keyword in enumerate(element.getchildren()): if keyword.text is not None: yield Keyword( self.pmid, owner, cnt + 1, keyword.text.strip(), keyword.get('MajorTopicYN', 'N') == 'Y', )
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 parse(self, _): for i in self.instances: yield i class TestDump(unittest.TestCase): def setUp(self):
def testRelations(self): i = Keyword(1, 'NASA', 1, 'name') self.sess.add(i) self.sess.commit() self.assertEqual([i], self.M.keywords) self.assertEqual(self.M, i.citation)
def testToRepr(self): self.assertEqual('Keyword<1:NASA:1>', repr(Keyword(1, 'NASA', 1, 'name')))
def testToString(self): self.assertEqual('1\tNASA\t1\tF\tname\n', str(Keyword(1, 'NASA', 1, 'name'))) self.assertEqual('1\tNASA\t1\tT\tname\n', str(Keyword(1, 'NASA', 1, 'name', True)))
def testMajorIsBool(self): self.sess.add(Keyword(1, 'NLM', 1, 'name', None)) self.assertRaises(IntegrityError, self.sess.commit)