8
8
9
9
class DataSourceTest (BaseTestCase ):
10
10
def test_get_schema (self ):
11
- return_value = [{"name" : "table" , "columns" : []}]
11
+ return_value = [{"name" : "table" , "columns" : [], "description" : None }]
12
12
13
13
with mock .patch ("redash.query_runner.pg.PostgreSQL.get_schema" ) as patched_get_schema :
14
14
patched_get_schema .return_value = return_value
@@ -18,7 +18,7 @@ def test_get_schema(self):
18
18
self .assertEqual (return_value , schema )
19
19
20
20
def test_get_schema_uses_cache (self ):
21
- return_value = [{"name" : "table" , "columns" : []}]
21
+ return_value = [{"name" : "table" , "columns" : [], "description" : None }]
22
22
with mock .patch ("redash.query_runner.pg.PostgreSQL.get_schema" ) as patched_get_schema :
23
23
patched_get_schema .return_value = return_value
24
24
@@ -29,12 +29,12 @@ def test_get_schema_uses_cache(self):
29
29
self .assertEqual (patched_get_schema .call_count , 1 )
30
30
31
31
def test_get_schema_skips_cache_with_refresh_true (self ):
32
- return_value = [{"name" : "table" , "columns" : []}]
32
+ return_value = [{"name" : "table" , "columns" : [], "description" : None }]
33
33
with mock .patch ("redash.query_runner.pg.PostgreSQL.get_schema" ) as patched_get_schema :
34
34
patched_get_schema .return_value = return_value
35
35
36
36
self .factory .data_source .get_schema ()
37
- new_return_value = [{"name" : "new_table" , "columns" : []}]
37
+ new_return_value = [{"name" : "new_table" , "columns" : [], "description" : None }]
38
38
patched_get_schema .return_value = new_return_value
39
39
schema = self .factory .data_source .get_schema (refresh = True )
40
40
@@ -43,19 +43,21 @@ def test_get_schema_skips_cache_with_refresh_true(self):
43
43
44
44
def test_schema_sorter (self ):
45
45
input_data = [
46
- {"name" : "zoo" , "columns" : ["is_zebra" , "is_snake" , "is_cow" ]},
46
+ {"name" : "zoo" , "columns" : ["is_zebra" , "is_snake" , "is_cow" ], "description" : None },
47
47
{
48
48
"name" : "all_terain_vehicle" ,
49
49
"columns" : ["has_wheels" , "has_engine" , "has_all_wheel_drive" ],
50
+ "description" : None ,
50
51
},
51
52
]
52
53
53
54
expected_output = [
54
55
{
55
56
"name" : "all_terain_vehicle" ,
56
57
"columns" : ["has_all_wheel_drive" , "has_engine" , "has_wheels" ],
58
+ "description" : None ,
57
59
},
58
- {"name" : "zoo" , "columns" : ["is_cow" , "is_snake" , "is_zebra" ]},
60
+ {"name" : "zoo" , "columns" : ["is_cow" , "is_snake" , "is_zebra" ], "description" : None },
59
61
]
60
62
61
63
real_output = self .factory .data_source ._sort_schema (input_data )
@@ -64,19 +66,21 @@ def test_schema_sorter(self):
64
66
65
67
def test_model_uses_schema_sorter (self ):
66
68
orig_schema = [
67
- {"name" : "zoo" , "columns" : ["is_zebra" , "is_snake" , "is_cow" ]},
69
+ {"name" : "zoo" , "columns" : ["is_zebra" , "is_snake" , "is_cow" ], "description" : None },
68
70
{
69
71
"name" : "all_terain_vehicle" ,
70
72
"columns" : ["has_wheels" , "has_engine" , "has_all_wheel_drive" ],
73
+ "description" : None ,
71
74
},
72
75
]
73
76
74
77
sorted_schema = [
75
78
{
76
79
"name" : "all_terain_vehicle" ,
77
80
"columns" : ["has_all_wheel_drive" , "has_engine" , "has_wheels" ],
81
+ "description" : None ,
78
82
},
79
- {"name" : "zoo" , "columns" : ["is_cow" , "is_snake" , "is_zebra" ]},
83
+ {"name" : "zoo" , "columns" : ["is_cow" , "is_snake" , "is_zebra" ], "description" : None },
80
84
]
81
85
82
86
with mock .patch ("redash.query_runner.pg.PostgreSQL.get_schema" ) as patched_get_schema :
0 commit comments