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:
Alanna Scott 2017-06-13 09:44:26 -07:00 committed by GitHub
parent e5151cb915
commit e1751c065c
2 changed files with 10 additions and 3 deletions

View File

@ -380,7 +380,7 @@ class SliceModelView(SupersetModelView, DeleteMixin): # noqa
return self.render_template(
"superset/add_slice.html",
bootstrap_data=json.dumps({
'datasources': sorted(datasources),
'datasources': sorted(datasources, key=lambda d: d["label"]),
}),
)

View File

@ -216,17 +216,24 @@ class CoreTests(SupersetTestCase):
logging.info("[{name}]/[{method}]: {url}".format(**locals()))
self.client.get(url)
def test_add_slice(self):
def test_tablemodelview_list(self):
self.login(username='admin')
# Click on the + to add a slice
url = '/tablemodelview/list/'
resp = self.get_resp(url)
# assert that a table is listed
table = db.session.query(SqlaTable).first()
assert table.name 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):
# Add explore-v2-beta role to admin user
# Test all slice urls as user with with explore-v2-beta role