mirror of https://github.com/apache/superset.git
add new slice test (#2939)
* sort explicitly on label * add simple test for /slicemodelview/add endpoint * make comments and method names more clear * fix test name * be more explicit, test status_code
This commit is contained in:
parent
e5151cb915
commit
e1751c065c
|
@ -380,7 +380,7 @@ class SliceModelView(SupersetModelView, DeleteMixin): # noqa
|
||||||
return self.render_template(
|
return self.render_template(
|
||||||
"superset/add_slice.html",
|
"superset/add_slice.html",
|
||||||
bootstrap_data=json.dumps({
|
bootstrap_data=json.dumps({
|
||||||
'datasources': sorted(datasources),
|
'datasources': sorted(datasources, key=lambda d: d["label"]),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -216,17 +216,24 @@ class CoreTests(SupersetTestCase):
|
||||||
logging.info("[{name}]/[{method}]: {url}".format(**locals()))
|
logging.info("[{name}]/[{method}]: {url}".format(**locals()))
|
||||||
self.client.get(url)
|
self.client.get(url)
|
||||||
|
|
||||||
def test_add_slice(self):
|
def test_tablemodelview_list(self):
|
||||||
self.login(username='admin')
|
self.login(username='admin')
|
||||||
|
|
||||||
# Click on the + to add a slice
|
|
||||||
url = '/tablemodelview/list/'
|
url = '/tablemodelview/list/'
|
||||||
resp = self.get_resp(url)
|
resp = self.get_resp(url)
|
||||||
|
|
||||||
|
# assert that a table is listed
|
||||||
table = db.session.query(SqlaTable).first()
|
table = db.session.query(SqlaTable).first()
|
||||||
assert table.name in resp
|
assert table.name in resp
|
||||||
assert '/superset/explore/table/{}'.format(table.id) in resp
|
assert '/superset/explore/table/{}'.format(table.id) in resp
|
||||||
|
|
||||||
|
def test_add_slice(self):
|
||||||
|
self.login(username='admin')
|
||||||
|
# assert that /slicemodelview/add responds with 200
|
||||||
|
url = '/slicemodelview/add'
|
||||||
|
resp = self.client.get(url)
|
||||||
|
self.assertEqual(resp.status_code, 200)
|
||||||
|
|
||||||
def test_slices_V2(self):
|
def test_slices_V2(self):
|
||||||
# Add explore-v2-beta role to admin user
|
# Add explore-v2-beta role to admin user
|
||||||
# Test all slice urls as user with with explore-v2-beta role
|
# Test all slice urls as user with with explore-v2-beta role
|
||||||
|
|
Loading…
Reference in New Issue