mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 01:00:14 -04:00
* Added support for Apache Drill datasource * Improvements in `Drill` query runner and minor refactoring 1. Drill query runner now inherits from `BaseHTTPQueryRunner`, because they both have a lot of common code. 2. `BaseHTTPQueryRunner.get_response` method now accepts `http_method` argument (original implementation was only capable of sending `GET` HTTP requests). 3. Added `order` to `BaseHTTPRequestRunner` configuration schema to fix order of UI elements based on the schema. 4. Eliminated duplicate method `_guess_type` in `GoogleSpreadsheet`, `Results` and `Drill` query runners, moved `guess_type` to `redash.query_runner`. 5. Removed tests for `_guess_type` in `GoogleSpreadsheet`, `Results` and `Drill` query runners, merged them into single test case and moved to `tests.query_runner.test_utils`. 6. Various minor changes (code style, imports, etc).
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from unittest import TestCase
|
|
|
|
from redash.query_runner import TYPE_DATETIME, TYPE_FLOAT, TYPE_INTEGER, TYPE_BOOLEAN, TYPE_STRING
|
|
from redash.query_runner.drill import guess_type
|
|
|
|
|
|
class TestGuessType(TestCase):
|
|
def test_handles_unicode(self):
|
|
self.assertEqual(guess_type(u'Текст'), TYPE_STRING)
|
|
|
|
def test_detects_booleans(self):
|
|
self.assertEqual(guess_type('true'), TYPE_BOOLEAN)
|
|
self.assertEqual(guess_type('True'), TYPE_BOOLEAN)
|
|
self.assertEqual(guess_type('TRUE'), TYPE_BOOLEAN)
|
|
self.assertEqual(guess_type('false'), TYPE_BOOLEAN)
|
|
self.assertEqual(guess_type('False'), TYPE_BOOLEAN)
|
|
self.assertEqual(guess_type('FALSE'), TYPE_BOOLEAN)
|
|
|
|
def test_detects_strings(self):
|
|
self.assertEqual(guess_type(None), TYPE_STRING)
|
|
self.assertEqual(guess_type(''), TYPE_STRING)
|
|
self.assertEqual(guess_type('redash'), TYPE_STRING)
|
|
|
|
def test_detects_integer(self):
|
|
self.assertEqual(guess_type('42'), TYPE_INTEGER)
|
|
|
|
def test_detects_float(self):
|
|
self.assertEqual(guess_type('3.14'), TYPE_FLOAT)
|
|
|
|
def test_detects_date(self):
|
|
self.assertEqual(guess_type('2018-10-31'), TYPE_DATETIME)
|