test_common.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:eggsnspam 作者: wayfair 项目源码 文件源码
def test_fetchone(self):
        """It gets a single row"""
        query = text("""
        SELECT id, name FROM tblExample
        WHERE id=:id;
        """)
        # Expect one record to be returned
        result = self.dao.fetchone(query, id=1)
        self.assertDictEqual(result, {'id': 1, 'name': 'Foo'})

        # Expect None to be returned if
        result = self.dao.fetchone(query, id=-1)
        self.assertEqual(result, None)

        # Expect one record to be returned even if multiple rows
        result = self.dao.fetchone('SELECT id, name FROM tblExample ORDER BY id')
        self.assertDictEqual(result, {'id': 1, 'name': 'Foo'})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号