redash/tests/handlers/test_embed.py

30 lines
1.1 KiB
Python
Raw Normal View History

2016-01-16 19:25:19 +00:00
from tests import BaseTestCase
class TestEmbedVisualization(BaseTestCase):
def test_sucesss(self):
vis = self.factory.create_visualization()
vis.query.latest_query_data = self.factory.create_query_result()
vis.query.save()
res = self.make_request("get", "/embed/query/{}/visualization/{}".format(vis.query.id, vis.id), is_json=False)
self.assertEqual(res.status_code, 200)
2016-02-21 12:08:49 +00:00
class TestPublicDashboard(BaseTestCase):
def test_success(self):
dashboard = self.factory.create_dashboard()
api_key = self.factory.create_api_key(object=dashboard)
res = self.make_request('get', '/public/dashboards/{}'.format(api_key.api_key), user=False, is_json=False)
self.assertEqual(res.status_code, 200)
def test_bad_token(self):
res = self.make_request('get', '/public/dashboards/bad-token', user=False, is_json=False)
self.assertEqual(res.status_code, 302)
# Not relevant for now, as tokens in api_keys table are only created for dashboards. Once this changes, we should
# add this test.
# def test_token_doesnt_belong_to_dashboard(self):
# pass