示例#1
0
文件: test_timers.py 项目: rahmiy/st2
    def setUpClass(cls):
        super(TestTimersHolder, cls).setUpClass()

        loader = FixturesLoader()
        TestTimersHolder.MODELS = loader.load_fixtures(
            fixtures_pack=PACK, fixtures_dict=FIXTURES)['triggers']
        loader.save_fixtures_to_db(fixtures_pack=PACK, fixtures_dict=FIXTURES)
示例#2
0
    def setUpClass(cls):
        super(TestTimersHolder, cls).setUpClass()

        loader = FixturesLoader()
        TestTimersHolder.MODELS = loader.load_fixtures(
            fixtures_pack=PACK, fixtures_dict=FIXTURES)['triggers']
        loader.save_fixtures_to_db(fixtures_pack=PACK, fixtures_dict=FIXTURES)
示例#3
0
    def test_create_trigger_db_from_rule_duplicate(self):
        test_fixtures = {
            'rules': ['cron_timer_rule_1.yaml', 'cron_timer_rule_2.yaml']
        }
        loader = FixturesLoader()
        fixtures = loader.load_fixtures(fixtures_pack='generic', fixtures_dict=test_fixtures)
        rules = fixtures['rules']

        trigger_db_ret_1 = trigger_service.create_trigger_db_from_rule(
            RuleAPI(**rules['cron_timer_rule_1.yaml']))
        self.assertTrue(trigger_db_ret_1 is not None)
        trigger_db_ret_2 = trigger_service.create_trigger_db_from_rule(
            RuleAPI(**rules['cron_timer_rule_2.yaml']))
        self.assertTrue(trigger_db_ret_2 is not None)
        self.assertEqual(trigger_db_ret_1, trigger_db_ret_2, 'Should reuse same trigger.')
        trigger_db = Trigger.get_by_id(trigger_db_ret_1.id)
        self.assertDictEqual(trigger_db.parameters,
                             rules['cron_timer_rule_1.yaml']['trigger']['parameters'])
示例#4
0
    def test_create_trigger_db_from_rule_duplicate(self):
        test_fixtures = {
            "rules": ["cron_timer_rule_1.yaml", "cron_timer_rule_2.yaml"]
        }
        loader = FixturesLoader()
        fixtures = loader.load_fixtures(fixtures_pack="generic",
                                        fixtures_dict=test_fixtures)
        rules = fixtures["rules"]

        trigger_db_ret_1 = trigger_service.create_trigger_db_from_rule(
            RuleAPI(**rules["cron_timer_rule_1.yaml"]))
        self.assertIsNotNone(trigger_db_ret_1)
        trigger_db_ret_2 = trigger_service.create_trigger_db_from_rule(
            RuleAPI(**rules["cron_timer_rule_2.yaml"]))
        self.assertIsNotNone(trigger_db_ret_2)
        self.assertEqual(trigger_db_ret_1, trigger_db_ret_2,
                         "Should reuse same trigger.")
        trigger_db = Trigger.get_by_id(trigger_db_ret_1.id)
        self.assertDictEqual(
            trigger_db.parameters,
            rules["cron_timer_rule_1.yaml"]["trigger"]["parameters"],
        )
        WF_INVALID_YAQL_FILE
    ],
    'actions': [
        'a1.yaml',
        'a2.yaml',
        'action1.yaml'
    ],
    'runners': [
        'testrunner1.yaml',
        'testrunner2.yaml'
    ]
}

PACK = 'generic'
LOADER = FixturesLoader()
FIXTURES = LOADER.load_fixtures(fixtures_pack=PACK, fixtures_dict=TEST_FIXTURES)
WB_PRE_XFORM_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WB_PRE_XFORM_FILE)
WB_INVALID_SYNTAX_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WB_INVALID_SYNTAX_FILE)
WB_INVALID_YAQL_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WB_INVALID_YAQL_FILE)
WF_PRE_XFORM_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WF_PRE_XFORM_FILE)
WF_NO_REQ_PARAM_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WF_NO_REQ_PARAM_FILE)
WF_UNEXP_PARAM_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WF_UNEXP_PARAM_FILE)
WF_INVALID_SYNTAX_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WF_INVALID_SYNTAX_FILE)
WF_INVALID_YAQL_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WF_INVALID_YAQL_FILE)


class MistralValidationControllerTest(FunctionalTest):

    @classmethod
    def setUpClass(cls):
        super(MistralValidationControllerTest, cls).setUpClass()
示例#6
0
from six.moves import http_client

from st2common.models.api.policy import PolicyTypeAPI, PolicyAPI
from st2common.persistence.policy import PolicyType, Policy
from st2common.transport.publishers import PoolPublisher
from st2tests.fixturesloader import FixturesLoader
from tests import FunctionalTest

TEST_FIXTURES = {
    'policytypes': ['fake_policy_type_1.yaml', 'fake_policy_type_2.yaml'],
    'policies': ['policy_1.yaml', 'policy_2.yaml']
}

PACK = 'generic'
LOADER = FixturesLoader()
FIXTURES = LOADER.load_fixtures(fixtures_pack=PACK,
                                fixtures_dict=TEST_FIXTURES)


class PolicyTypeControllerTest(FunctionalTest):
    base_url = '/v1/policytypes'

    @classmethod
    def setUpClass(cls):
        super(PolicyTypeControllerTest, cls).setUpClass()

        for _, fixture in six.iteritems(FIXTURES['policytypes']):
            instance = PolicyTypeAPI(**fixture)
            PolicyType.add_or_update(PolicyTypeAPI.to_model(instance))

    def test_policy_type_get_all(self):
        resp = self.__do_get_all()