本文整理匯總了Python中explorer.tests.factories.SimpleQueryFactory.params方法的典型用法代碼示例。如果您正苦於以下問題:Python SimpleQueryFactory.params方法的具體用法?Python SimpleQueryFactory.params怎麽用?Python SimpleQueryFactory.params使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類explorer.tests.factories.SimpleQueryFactory
的用法示例。
在下文中一共展示了SimpleQueryFactory.params方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_query_logs_final_sql
# 需要導入模塊: from explorer.tests.factories import SimpleQueryFactory [as 別名]
# 或者: from explorer.tests.factories.SimpleQueryFactory import params [as 別名]
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';")
示例2: test_params_get_merged
# 需要導入模塊: from explorer.tests.factories import SimpleQueryFactory [as 別名]
# 或者: from explorer.tests.factories.SimpleQueryFactory import params [as 別名]
def test_params_get_merged(self):
q = SimpleQueryFactory(sql="select '$$foo$$';")
q.params = {'foo': 'bar', 'mux': 'qux'}
self.assertEqual(q.available_params(), {'foo': 'bar'})
示例3: test_form_is_always_valid_with_params
# 需要導入模塊: from explorer.tests.factories import SimpleQueryFactory [as 別名]
# 或者: from explorer.tests.factories.SimpleQueryFactory import params [as 別名]
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())
示例4: test_form_fails_blacklist_even_with_params
# 需要導入模塊: from explorer.tests.factories import SimpleQueryFactory [as 別名]
# 或者: from explorer.tests.factories.SimpleQueryFactory import params [as 別名]
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())
示例5: test_final_sql_uses_merged_params
# 需要導入模塊: from explorer.tests.factories import SimpleQueryFactory [as 別名]
# 或者: from explorer.tests.factories.SimpleQueryFactory import params [as 別名]
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)
示例6: test_blacklist_prevents_bad_sql_with_params_from_executing
# 需要導入模塊: from explorer.tests.factories import SimpleQueryFactory [as 別名]
# 或者: from explorer.tests.factories.SimpleQueryFactory import params [as 別名]
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)