Permalink
Browse files

[hotfix] fix the logging fix that broke the build (#1940)

* [hotfix] fix the logging fix that broke the build

* Fixing tests
  • Loading branch information...
1 parent 5d94d70 commit 2d866e3ffa9bfedd3b3dad0d3463767aae879a14 @mistercrunch mistercrunch committed on GitHub Jan 11, 2017
Showing with 19 additions and 12 deletions.
  1. +4 −1 superset/models.py
  2. +9 −5 tests/core_tests.py
  3. +6 −6 tests/sqllab_tests.py
View
@@ -2586,6 +2586,8 @@ def wrapper(*args, **kwargs):
except:
pass
value = f(*args, **kwargs)
+
+ sesh = db.session()
log = cls(
action=f.__name__,
json=params,
@@ -2595,7 +2597,8 @@ def wrapper(*args, **kwargs):
datetime.now() - start_dttm).total_seconds() * 1000,
referrer=request.referrer[:1000] if request.referrer else None,
user_id=user_id)
- db.session.flush()
+ sesh.add(log)
+ sesh.commit()
return value
return wrapper
View
@@ -59,16 +59,20 @@ def test_slice_endpoint(self):
'/superset/slice/{}/?standalone=true'.format(slc.id))
assert 'List Roles' not in resp
- def test_endpoints_for_a_slice(self):
+ def test_slice_json_endpoint(self):
self.login(username='admin')
slc = self.get_slice("Girls", db.session)
- resp = self.get_resp(slc.viz.csv_endpoint)
- assert 'Jennifer,' in resp
-
resp = self.get_resp(slc.viz.json_endpoint)
assert '"Jennifer"' in resp
+ def test_slice_csv_endpoint(self):
+ self.login(username='admin')
+ slc = self.get_slice("Girls", db.session)
+
+ resp = self.get_resp(slc.viz.csv_endpoint)
+ assert 'Jennifer,' in resp
+
def test_admin_only_permissions(self):
def assert_admin_permission_in(role_name, assert_func):
role = sm.find_role(role_name)
@@ -466,14 +470,14 @@ def test_templated_sql_json(self):
def test_table_metadata(self):
maindb = self.get_main_database(db.session)
+ backend = maindb.backend
data = self.get_json_resp(
"/superset/table/{}/ab_user/null/".format(maindb.id))
self.assertEqual(data['name'], 'ab_user')
assert len(data['columns']) > 5
assert data.get('selectStar').startswith('SELECT')
# Engine specific tests
- backend = maindb.backend
if backend in ('mysql', 'postgresql'):
self.assertEqual(data.get('primaryKey').get('type'), 'pk')
self.assertEqual(
View
@@ -133,19 +133,19 @@ def test_search_query_on_user(self):
self.login('admin')
# Test search queries on user Id
- user = appbuilder.sm.find_user('admin')
+ user_id = appbuilder.sm.find_user('admin').id
data = self.get_json_resp(
- '/superset/search_queries?user_id={}'.format(user.id))
+ '/superset/search_queries?user_id={}'.format(user_id))
self.assertEquals(2, len(data))
user_ids = {k['userId'] for k in data}
- self.assertEquals(set([user.id]), user_ids)
+ self.assertEquals(set([user_id]), user_ids)
- user = appbuilder.sm.find_user('gamma_sqllab')
+ user_id = appbuilder.sm.find_user('gamma_sqllab').id
resp = self.get_resp(
- '/superset/search_queries?user_id={}'.format(user.id))
+ '/superset/search_queries?user_id={}'.format(user_id))
data = json.loads(resp)
self.assertEquals(1, len(data))
- self.assertEquals(data[0]['userId'] , user.id)
+ self.assertEquals(data[0]['userId'] , user_id)
def test_search_query_on_status(self):
self.run_some_queries()

0 comments on commit 2d866e3

Please sign in to comment.