@@ -199,22 +199,38 @@ def test_saved_dashboard_errors_sql_not_in_textarea(admin_client, saved_dashboar
199
199
assert '<pre class="sql">this is bad</pre>' in html
200
200
201
201
202
- def test_dashboard_show_available_tables (admin_client , dashboard_db ):
202
+ def test_dashboard_show_available_tables (admin_client ):
203
203
response = admin_client .get ("/dashboard/" )
204
204
soup = BeautifulSoup (response .content , "html5lib" )
205
205
lis = soup .find ("ul" ).findAll ("li" )
206
206
details = [
207
- {"table" : li .find ("a" ).text , "columns" : li .find ("p" ).text }
207
+ {
208
+ "table" : li .find ("a" ).text ,
209
+ "columns" : li .find ("p" ).text ,
210
+ "href" : li .find ("a" )["href" ],
211
+ }
208
212
for li in lis
209
213
if li .find ("a" ).text .startswith ("django_sql_dashboard" )
214
+ or li .find ("a" ).text == "switches"
210
215
]
216
+ # Decode the href in each one into a SQL query
217
+ for detail in details :
218
+ href = detail .pop ("href" )
219
+ detail ["href_sql" ] = urllib .parse .parse_qs (href )["sql" ][0 ].rsplit (":" , 1 )[0 ]
211
220
assert details == [
212
221
{
213
222
"table" : "django_sql_dashboard_dashboard" ,
214
223
"columns" : "id, slug, title, description, created_at, edit_group_id, edit_policy, owned_by_id, view_group_id, view_policy" ,
224
+ "href_sql" : "select id, slug, title, description, created_at, edit_group_id, edit_policy, owned_by_id, view_group_id, view_policy from django_sql_dashboard_dashboard" ,
215
225
},
216
226
{
217
227
"table" : "django_sql_dashboard_dashboardquery" ,
218
228
"columns" : "id, sql, dashboard_id, _order" ,
229
+ "href_sql" : "select id, sql, dashboard_id, _order from django_sql_dashboard_dashboardquery" ,
230
+ },
231
+ {
232
+ "table" : "switches" ,
233
+ "columns" : "id, name, on" ,
234
+ "href_sql" : 'select id, name, "on" from switches' ,
219
235
},
220
236
]
0 commit comments