當前位置: 首頁>>代碼示例>>Python>>正文


Python factories.SimpleQueryFactory類代碼示例

本文整理匯總了Python中explorer.tests.factories.SimpleQueryFactory的典型用法代碼示例。如果您正苦於以下問題:Python SimpleQueryFactory類的具體用法?Python SimpleQueryFactory怎麽用?Python SimpleQueryFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SimpleQueryFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的explorer.tests.factories.SimpleQueryFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。