<s> import six <EOL> from st2tests . fixturesloader import FixturesLoader <EOL> from tests import FunctionalTest <EOL> http_client = six . moves . http_client <EOL> TEST_FIXTURES = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> } <EOL> FIXTURES_PACK = '<STR_LIT>' <EOL> class TestRuleEnforcementController ( FunctionalTest ) : <EOL> fixtures_loader = FixturesLoader ( ) <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TestRuleEnforcementController , cls ) . setUpClass ( ) <EOL> models = TestRuleEnforcementController . fixtures_loader . save_fixtures_to_db ( <EOL> fixtures_pack = FIXTURES_PACK , fixtures_dict = TEST_FIXTURES ) <EOL> TestRuleEnforcementController . ENFORCEMENT_1 = models [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> def test_get_all ( self ) : <EOL> resp = self . app . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( len ( resp . json ) , <NUM_LIT:3> ) <EOL> def test_get_one_by_id ( self ) : <EOL> e_id = str ( TestRuleEnforcementController . ENFORCEMENT_1 . id ) <EOL> resp = self . app . get ( '<STR_LIT>' % e_id ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( resp . json [ '<STR_LIT:id>' ] , e_id ) <EOL> def test_get_one_fail ( self ) : <EOL> resp = self . app . get ( '<STR_LIT>' , expect_errors = True ) <EOL> self . assertEqual ( resp . status_int , http_client . NOT_FOUND ) <EOL> def test_filter_by_rule_ref ( self ) : <EOL> resp = self . app . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( len ( resp . json ) , <NUM_LIT:1> ) <EOL> def test_filter_by_rule_id ( self ) : <EOL> resp = self . app . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( len ( resp . json ) , <NUM_LIT:2> ) <EOL> def test_filter_by_execution_id ( self ) : <EOL> resp = self . app . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( len ( resp . json ) , <NUM_LIT:1> ) <EOL> def test_filter_by_trigger_instance_id ( self ) : <EOL> resp = self . app . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( len ( resp . json ) , <NUM_LIT:1> ) <EOL> def test_filter_by_enforced_at ( self ) : <EOL> resp = self . app . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( len ( resp . json ) , <NUM_LIT:2> ) <EOL> resp = self . app . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( resp . status_int , http_client . OK ) <EOL> self . assertEqual ( len ( resp . json ) , <NUM_LIT:1> ) </s>
