Пример #1
0
    def test_disables_api_key(self):
        dashboard = self.factory.create_dashboard()
        ApiKey.create_for_object(dashboard, self.factory.user)

        res = self.make_request('delete', '/api/dashboards/{}/share'.format(dashboard.id))
        self.assertEqual(res.status_code, 200)
        self.assertIsNone(ApiKey.get_by_object(dashboard))
    def test_returns_only_active_key(self):
        dashboard = self.factory.create_dashboard()
        api_key = self.factory.create_api_key(object=dashboard, active=False)
        self.assertIsNone(ApiKey.get_by_object(dashboard))

        api_key = self.factory.create_api_key(object=dashboard)
        self.assertEqual(api_key, ApiKey.get_by_object(dashboard))
Пример #3
0
    def test_returns_only_active_key(self):
        dashboard = self.factory.create_dashboard()
        api_key = self.factory.create_api_key(object=dashboard, active=False)
        self.assertIsNone(ApiKey.get_by_object(dashboard))

        api_key = self.factory.create_api_key(object=dashboard)
        self.assertEqual(api_key, ApiKey.get_by_object(dashboard))
Пример #4
0
    def test_disables_api_key(self):
        dashboard = self.factory.create_dashboard()
        ApiKey.create_for_object(dashboard, self.factory.user)

        res = self.make_request('delete', '/api/dashboards/{}/share'.format(dashboard.id))
        self.assertEqual(res.status_code, 200)
        self.assertIsNone(ApiKey.get_by_object(dashboard))
Пример #5
0
    def test_creates_api_key(self):
        dashboard = self.factory.create_dashboard()

        res = self.make_request(
            'post', '/api/dashboards/{}/share'.format(dashboard.id))
        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.json['api_key'],
                         ApiKey.get_by_object(dashboard).api_key)
 def test_returns_none_if_not_exists(self):
     dashboard = self.factory.create_dashboard()
     self.assertIsNone(ApiKey.get_by_object(dashboard))
from redash.models import ApiKey


if __name__ == '__main__':
    ApiKey.create_table()
Пример #8
0
    def test_creates_api_key(self):
        dashboard = self.factory.create_dashboard()

        res = self.make_request('post', '/api/dashboards/{}/share'.format(dashboard.id))
        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.json['api_key'], ApiKey.get_by_object(dashboard).api_key)
Пример #9
0
from redash.models import ApiKey

if __name__ == '__main__':
    ApiKey.create_table()
Пример #10
0
 def test_returns_none_if_not_exists(self):
     dashboard = self.factory.create_dashboard()
     self.assertIsNone(ApiKey.get_by_object(dashboard))