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