Skip to content

Commit

Permalink
add new slice test (#2939)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Alanna Scott authored Jun 13, 2017
1 parent e5151cb commit e1751c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def add(self):
return self.render_template(
"superset/add_slice.html",
bootstrap_data=json.dumps({
'datasources': sorted(datasources),
'datasources': sorted(datasources, key=lambda d: d["label"]),
}),
)

Expand Down
11 changes: 9 additions & 2 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,24 @@ def test_slices(self):
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
Expand Down

0 comments on commit e1751c0

Please sign in to comment.