示例#1
0
文件: orm_test.py 项目: henn/medic
    def testInsertMultiple(self):
        d = date.today()
        data = {Citation.__tablename__: [
            dict(pmid=1, status='MEDLINE', title='Title 1',
                 journal='Journal 1', pub_date='PubDate', created=d),
            dict(pmid=2, status='MEDLINE', title='Title 2',
                 journal='Journal 2', pub_date='PubDate', created=d),
            dict(pmid=3, status='MEDLINE', title='Title 3',
                 journal='Journal 3', pub_date='PubDate', created=d)
        ]}
        Citation.insert(data)
        count = 0

        for m in self.sess.query(Citation):
            if m.pmid not in (1, 2, 3):
                self.fail(m)
            else:
                count += 1

        self.assertEqual(3, count)
示例#2
0
文件: orm_test.py 项目: henn/medic
    def testInsert(self):
        data = {
            Citation.__tablename__: [
                dict(pmid=1, status='MEDLINE', title='Title', journal='Journal',
                     pub_date='PubDate', created=date.today())
            ],
            Abstract.__tablename__: [
                dict(pmid=1, source='NLM')
            ],
            Section.__tablename__: [
                dict(pmid=1, source='NLM', seq=1, name='Title', content='The title.')
            ],
            Author.__tablename__: [
                dict(pmid=1, pos=1, name='Author')
            ],
            Descriptor.__tablename__: [
                dict(pmid=1, num=1, major=True, name='descriptor')
            ],
            Qualifier.__tablename__: [
                dict(pmid=1, num=1, sub=1, major=True, name='descriptor')
            ],
            Identifier.__tablename__: [
                dict(pmid=1, namespace='ns', value='id')
            ],
            Database.__tablename__: [
                dict(pmid=1, name='name', accession='accession')
            ],
            Chemical.__tablename__: [
                dict(pmid=1, idx=1, name='name')
            ],
            Keyword.__tablename__: [
                dict(pmid=1, owner='NLM', cnt=1, major=True, value='name')
            ],
        }
        Citation.insert(data)

        for m in self.sess.query(Citation):
            self.assertEqual(1, m.pmid)

        for t in Citation.CHILDREN:
            self.assertEqual(1, list(self.sess.query(t))[0].pmid)
示例#3
0
    def testInsert(self):
        data = {
            Citation.__tablename__: [
                dict(pmid=1,
                     status='MEDLINE',
                     year=1990,
                     title='Title',
                     journal='Journal',
                     pub_date='1990 PubDate',
                     created=date.today())
            ],
            Abstract.__tablename__: [dict(pmid=1, source='NLM')],
            Section.__tablename__: [
                dict(pmid=1,
                     source='NLM',
                     seq=1,
                     name='Title',
                     content='The title.')
            ],
            Author.__tablename__: [dict(pmid=1, pos=1, name='Author')],
            Descriptor.__tablename__:
            [dict(pmid=1, num=1, major=True, name='descriptor')],
            Qualifier.__tablename__:
            [dict(pmid=1, num=1, sub=1, major=True, name='descriptor')],
            Identifier.__tablename__:
            [dict(pmid=1, namespace='ns', value='id')],
            Database.__tablename__:
            [dict(pmid=1, name='name', accession='accession')],
            Chemical.__tablename__: [dict(pmid=1, idx=1, name='name')],
            Keyword.__tablename__:
            [dict(pmid=1, owner='NLM', cnt=1, major=True, value='name')],
        }
        Citation.insert(data)

        for m in self.sess.query(Citation):
            self.assertEqual(1, m.pmid)

        for t in Citation.CHILDREN:
            self.assertEqual(1, list(self.sess.query(t))[0].pmid)
示例#4
0
    def testInsertMultiple(self):
        d = date.today()
        data = {
            Citation.__tablename__: [
                dict(pmid=1,
                     status='MEDLINE',
                     year=1990,
                     title='Title 1',
                     journal='Journal 1',
                     pub_date='1990 PubDate',
                     created=d),
                dict(pmid=2,
                     status='MEDLINE',
                     year=1990,
                     title='Title 2',
                     journal='Journal 2',
                     pub_date='1990 PubDate',
                     created=d),
                dict(pmid=3,
                     status='MEDLINE',
                     year=1990,
                     title='Title 3',
                     journal='Journal 3',
                     pub_date='1990 PubDate',
                     created=d)
            ]
        }
        Citation.insert(data)
        count = 0

        for m in self.sess.query(Citation):
            if m.pmid not in (1, 2, 3):
                self.fail(m)
            else:
                count += 1

        self.assertEqual(3, count)