• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factories.SimpleQueryFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中explorer.tests.factories.SimpleQueryFactory的典型用法代码示例。如果您正苦于以下问题:Python SimpleQueryFactory类的具体用法?Python SimpleQueryFactory怎么用?Python SimpleQueryFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SimpleQueryFactory类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_query_logs_final_sql

 def test_query_logs_final_sql(self):
     q = SimpleQueryFactory(sql="select '$$foo$$';")
     q.params = {'foo': 'bar'}
     q.log(None)
     self.assertEqual(1, QueryLog.objects.count())
     log = QueryLog.objects.first()
     self.assertEqual(log.sql, "select 'bar';")
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:7,代码来源:test_models.py


示例2: test_get_run_count

 def test_get_run_count(self):
     q = SimpleQueryFactory()
     self.assertEqual(q.get_run_count(), 0)
     expected = 4
     for i in range(0, expected):
         q.log()
     self.assertEqual(q.get_run_count(), expected)
开发者ID:nickspacek,项目名称:django-sql-explorer,代码行数:7,代码来源:test_models.py


示例3: test_simple_query_runs

    def test_simple_query_runs(self):

        expected_csv = 'two\r\n2\r\n'

        r = SimpleQueryFactory()
        result = r.csv_report()

        self.assertIsNotNone(result, "Query '%s' returned None." % r.title)
        self.assertEqual(result.lower(), expected_csv)
开发者ID:azizmb,项目名称:django-sql-explorer,代码行数:9,代码来源:test_actions.py


示例4: test_query_log

 def test_query_log(self):
     self.assertEqual(0, QueryLog.objects.count())
     q = SimpleQueryFactory()
     q.log(None)
     self.assertEqual(1, QueryLog.objects.count())
     log = QueryLog.objects.first()
     self.assertEqual(log.run_by_user, None)
     self.assertEqual(log.query, q)
     self.assertFalse(log.is_playground)
开发者ID:nickspacek,项目名称:django-sql-explorer,代码行数:9,代码来源:test_models.py


示例5: test_avg_duration

 def test_avg_duration(self):
     q = SimpleQueryFactory()
     self.assertIsNone(q.avg_duration())
     expected = 2.5
     ql = q.log()
     ql.duration = 2
     ql.save()
     ql = q.log()
     ql.duration = 3
     ql.save()
     self.assertEqual(q.avg_duration(), expected)
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:11,代码来源:test_models.py


示例6: setUp

 def setUp(self):
     self.user = User.objects.create_superuser("admin", "[email protected]", "pwd")
     self.user2 = User.objects.create_superuser("admin2", "[email protected]", "pwd")
     self.client.login(username="admin", password="pwd")
     self.query = SimpleQueryFactory.build()
     self.data = model_to_dict(self.query)
     self.data["created_by_user"] = 2
开发者ID:roojoom,项目名称:django-sql-explorer,代码行数:7,代码来源:test_views.py


示例7: test_run_count

 def test_run_count(self):
     q = SimpleQueryFactory(title='foo - bar1')
     for i in range(0, 4):
         q.log()
     resp = self.client.get(reverse("explorer_index"))
     self.assertContains(resp, '<td>4</td>')
开发者ID:nickspacek,项目名称:django-sql-explorer,代码行数:6,代码来源:test_views.py


示例8: test_blacklist_check_runs_before_execution

 def test_blacklist_check_runs_before_execution(self):
     q = SimpleQueryFactory(sql='select 1;')
     with AssertMethodIsCalled(q, "passes_blacklist"):
         headers, data, duration, error = q.headers_and_data()
开发者ID:azizmb,项目名称:django-sql-explorer,代码行数:4,代码来源:test_models.py


示例9: test_blacklist_prevents_bad_sql_from_executing

 def test_blacklist_prevents_bad_sql_from_executing(self):
     q = SimpleQueryFactory(sql='select 1 "delete";')
     headers, data, duration, error = q.headers_and_data()
     self.assertEqual(error, MSG_FAILED_BLACKLIST)
开发者ID:azizmb,项目名称:django-sql-explorer,代码行数:4,代码来源:test_models.py


示例10: test_params_get_merged

 def test_params_get_merged(self):
     q = SimpleQueryFactory(sql="select '$$foo$$';")
     q.params = {'foo': 'bar', 'mux': 'qux'}
     self.assertEqual(q.available_params(), {'foo': 'bar'})
开发者ID:azizmb,项目名称:django-sql-explorer,代码行数:4,代码来源:test_models.py


示例11: test_form_fails_blacklist_even_with_params

 def test_form_fails_blacklist_even_with_params(self):
     q = SimpleQueryFactory(sql="delete $$a$$;", created_by_user_id=None)
     q.params = {}
     form = QueryForm(model_to_dict(q))
     self.assertFalse(form.is_valid())
开发者ID:valferon,项目名称:django-brandfin,代码行数:5,代码来源:test_forms.py


示例12: test_form_is_always_valid_with_params

 def test_form_is_always_valid_with_params(self):
     q = SimpleQueryFactory(sql="select $$a$$;")
     q.params = {}
     form = QueryForm(model_to_dict(q))
     self.assertTrue(form.is_valid())
开发者ID:azizmb,项目名称:django-sql-explorer,代码行数:5,代码来源:test_forms.py


示例13: test_blacklist_prevents_bad_sql_with_params_from_executing

 def test_blacklist_prevents_bad_sql_with_params_from_executing(self):
     q = SimpleQueryFactory(sql="select '$$foo$$';")
     q.params = {"foo": "'; delete from *; select'"}
     res = q.headers_and_data()
     self.assertEqual(res.error, MSG_FAILED_BLACKLIST)
开发者ID:alrvivas,项目名称:rh_campo,代码行数:5,代码来源:test_models.py


示例14: test_final_sql_uses_merged_params

 def test_final_sql_uses_merged_params(self):
     q = SimpleQueryFactory(sql="select '$$foo:bar$$', '$$qux$$';")
     q.params = {'qux': 'mux'}
     expected = "select 'bar', 'mux';"
     self.assertEqual(q.final_sql(), expected)
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:5,代码来源:test_models.py


示例15: test_log_saves_duration

 def test_log_saves_duration(self):
     q = SimpleQueryFactory()
     res, ql = q.execute_with_logging(None)
     log = QueryLog.objects.first()
     self.assertEqual(log.duration, res.duration)
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:5,代码来源:test_models.py


示例16: test_default_params_used

 def test_default_params_used(self):
     q = SimpleQueryFactory(sql="select '$$foo:bar$$';")
     self.assertEqual(q.available_params(), {'foo': 'bar'})
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:3,代码来源:test_models.py



注:本文中的explorer.tests.factories.SimpleQueryFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python misc.Response类代码示例发布时间:2022-05-24
下一篇:
Python models.Query类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap