Files
redash/tests/models/test_alerts.py
Arik Fraimovich f7b57fa580 Feature: new permissions system
This is one huge change for the permissions system and related:

* (Backward incompatible:) Remove the table based permissions in favour of the new model.
* Manage permission to view or query datasources based on groups.
* Add the concept of Organization. It's irrelevant for most deployments, but allows for
  multi-tenant support in re:dash.
* Replace ActivityLog with Event based rows (old data in activity_log table is retained).
* Enforce permissions on the server-side. There were some permissions that were only enforced
  on the client side. This is no more. All permissions are enforced by the server.
* Added new permission: 'super-admin' to access the status and Flask-Admin interface.
* Make sure that html is never cached by the browser - this is to make sure that the browser
  will always ask for the new Javascript/CSS resources (if such are available).
2015-12-31 10:43:33 +02:00

28 lines
948 B
Python

from tests import BaseTestCase
from redash.models import Alert
class TestAlertAll(BaseTestCase):
def test_returns_all_alerts_for_given_groups(self):
ds1 = self.factory.data_source
group = self.factory.create_group()
ds2 = self.factory.create_data_source(group=group)
query1 = self.factory.create_query(data_source=ds1)
query2 = self.factory.create_query(data_source=ds2)
alert1 = self.factory.create_alert(query=query1)
alert2 = self.factory.create_alert(query=query2)
alerts = Alert.all(groups=[group, self.factory.default_group])
self.assertIn(alert1, alerts)
self.assertIn(alert2, alerts)
alerts = Alert.all(groups=[self.factory.default_group])
self.assertIn(alert1, alerts)
self.assertNotIn(alert2, alerts)
alerts = Alert.all(groups=[group])
self.assertNotIn(alert1, alerts)
self.assertIn(alert2, alerts)