本文整理汇总了Python中st2tests.fixturesloader.FixturesLoader类的典型用法代码示例。如果您正苦于以下问题:Python FixturesLoader类的具体用法?Python FixturesLoader怎么用?Python FixturesLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FixturesLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
def setUpClass(cls):
EventletTestCase.setUpClass()
DbTestCase.setUpClass()
loader = FixturesLoader()
loader.save_fixtures_to_db(fixtures_pack=PACK,
fixtures_dict=TEST_FIXTURES)
示例2: setUpClass
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: test_create_or_update_trigger_db_simple_triggers
def test_create_or_update_trigger_db_simple_triggers(self):
test_fixtures = {
'triggertypes': ['triggertype1.yaml']
}
loader = FixturesLoader()
fixtures = loader.save_fixtures_to_db(fixtures_pack='generic', fixtures_dict=test_fixtures)
triggertypes = fixtures['triggertypes']
trigger_type_ref = ResourceReference.to_string_reference(
name=triggertypes['triggertype1.yaml']['name'],
pack=triggertypes['triggertype1.yaml']['pack'])
trigger = {
'name': triggertypes['triggertype1.yaml']['name'],
'pack': triggertypes['triggertype1.yaml']['pack'],
'type': trigger_type_ref
}
trigger_service.create_or_update_trigger_db(trigger)
triggers = Trigger.get_all()
self.assertTrue(len(triggers) == 1, 'Only one trigger should be created.')
self.assertTrue(triggers[0]['name'] == triggertypes['triggertype1.yaml']['name'])
# Try adding duplicate
trigger_service.create_or_update_trigger_db(trigger)
triggers = Trigger.get_all()
self.assertTrue(len(triggers) == 1, 'Only one trigger should be present.')
self.assertTrue(triggers[0]['name'] == triggertypes['triggertype1.yaml']['name'])
示例4: test_exception_thrown_when_rule_creation_no_trigger_yes_triggertype
def test_exception_thrown_when_rule_creation_no_trigger_yes_triggertype(self):
test_fixtures = {
'triggertypes': ['triggertype1.yaml']
}
loader = FixturesLoader()
fixtures = loader.save_fixtures_to_db(fixtures_pack='generic', fixtures_dict=test_fixtures)
triggertypes = fixtures['triggertypes']
trigger_type_ref = ResourceReference.to_string_reference(
name=triggertypes['triggertype1.yaml']['name'],
pack=triggertypes['triggertype1.yaml']['pack'])
rule = {
'name': 'fancyrule',
'trigger': {
'type': trigger_type_ref
},
'criteria': {
},
'action': {
'ref': 'core.local',
'parameters': {
'cmd': 'date'
}
}
}
rule_api = RuleAPI(**rule)
self.assertRaises(TriggerDoesNotExistException,
trigger_service.create_trigger_db_from_rule, rule_api)
示例5: setUpClass
def setUpClass(cls):
super(BackstopRuleMatcherTestCase, cls).setUpClass()
fixturesloader = FixturesLoader()
# Create TriggerTypes before creation of Rule to avoid failure. Rule requires the
# Trigger and therefore TriggerType to be created prior to rule creation.
cls.models = fixturesloader.save_fixtures_to_db(
fixtures_pack=PACK, fixtures_dict=FIXTURES_TRIGGERS)
cls.models.update(fixturesloader.save_fixtures_to_db(
fixtures_pack=PACK, fixtures_dict=FIXTURES_RULES))
示例6: setUpClass
def setUpClass(cls):
EventletTestCase.setUpClass()
DbTestCase.setUpClass()
# Register common policy types
register_policy_types(st2common)
loader = FixturesLoader()
loader.save_fixtures_to_db(fixtures_pack=PACK, fixtures_dict=TEST_FIXTURES)
示例7: setUp
def setUp(self):
super(SchedulerPoliciesTest, self).setUp()
# Register common policy types
register_policy_types(st2common)
loader = FixturesLoader()
models = loader.save_fixtures_to_db(fixtures_pack=PACK,
fixtures_dict=TEST_FIXTURES_2)
# Policy with "post_run" application
self.policy_db = models['policies']['policy_1.yaml']
示例8: setUpClass
def setUpClass(cls):
ExecutionDbTestCase.setUpClass()
# Register runners
runners_registrar.register_runners()
# Register common policy types
register_policy_types(st2common)
loader = FixturesLoader()
loader.save_fixtures_to_db(fixtures_pack=PACK,
fixtures_dict=TEST_FIXTURES)
示例9: setUp
def setUp(self):
super(NotifierPoliciesTestCase, self).setUp()
# Register runners
runners_registrar.register_runners()
# Register common policy types
register_policy_types(st2common)
loader = FixturesLoader()
models = loader.save_fixtures_to_db(fixtures_pack=PACK,
fixtures_dict=TEST_FIXTURES_1)
# Policy with "post_run" application
self.policy_db = models['policies']['policy_4.yaml']
示例10: setUpClass
def setUpClass(cls):
EventletTestCase.setUpClass()
DbTestCase.setUpClass()
# Override the coordinator to use the noop driver otherwise the tests will be blocked.
tests_config.parse_args(coordinator_noop=True)
coordination.COORDINATOR = None
# Register runners
runners_registrar.register_runners()
# Register common policy types
register_policy_types(st2common)
loader = FixturesLoader()
loader.save_fixtures_to_db(fixtures_pack=PACK,
fixtures_dict=TEST_FIXTURES)
示例11: test_create_trigger_db_from_rule_duplicate
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'])
示例12: setUp
def setUp(self):
super(RetryPolicyTestCase, self).setUp()
# Register common policy types
register_policy_types(st2actions)
loader = FixturesLoader()
models = loader.save_fixtures_to_db(fixtures_pack=PACK,
fixtures_dict=TEST_FIXTURES)
# Instantiate policy applicator we will use in the tests
policy_db = models['policies']['policy_4.yaml']
retry_on = policy_db.parameters['retry_on']
max_retry_count = policy_db.parameters['max_retry_count']
self.policy = ExecutionRetryPolicyApplicator(policy_ref='test_policy',
policy_type='action.retry',
retry_on=retry_on,
max_retry_count=max_retry_count,
delay=0)
示例13: FixturesLoader
WF_INVALID_SYNTAX_FILE,
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):
示例14: FixturesLoader
WB_PRE_XFORM_FILE = 'wb_pre_xform.yaml'
WB_POST_XFORM_FILE = 'wb_post_xform.yaml'
WF_PRE_XFORM_FILE = 'wf_pre_xform.yaml'
WF_POST_XFORM_FILE = 'wf_post_xform.yaml'
TEST_FIXTURES = {
'workflows': [
WB_PRE_XFORM_FILE,
WB_POST_XFORM_FILE,
WF_PRE_XFORM_FILE,
WF_POST_XFORM_FILE
],
'actions': ['local.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_PRE_XFORM_DEF = FIXTURES['workflows'][WB_PRE_XFORM_FILE]
WB_POST_XFORM_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WB_POST_XFORM_FILE)
WB_POST_XFORM_DEF = FIXTURES['workflows'][WB_POST_XFORM_FILE]
WF_PRE_XFORM_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WF_PRE_XFORM_FILE)
WF_PRE_XFORM_DEF = FIXTURES['workflows'][WF_PRE_XFORM_FILE]
WF_POST_XFORM_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WF_POST_XFORM_FILE)
WF_POST_XFORM_DEF = FIXTURES['workflows'][WF_POST_XFORM_FILE]
def _read_file_content(path):
with open(path, 'r') as f:
return f.read()
示例15: FixturesLoader
'workflow_v2_many_workflows.yaml'
],
'actions': [
'workbook_v2.yaml',
'workbook_v2_many_workflows.yaml',
'workbook_v2_many_workflows_no_default.yaml',
'workflow_v2.yaml',
'workflow_v2_many_workflows.yaml',
'workbook_v2_name_mismatch.yaml',
'workflow_v2_name_mismatch.yaml',
'local.yaml'
]
}
PACK = 'generic'
LOADER = FixturesLoader()
FIXTURES = LOADER.load_fixtures(fixtures_pack=PACK, fixtures_dict=TEST_FIXTURES)
MISTRAL_EXECUTION = {'id': str(uuid.uuid4()), 'state': 'RUNNING', 'workflow_name': None}
# Workbook with a single workflow
WB1_YAML_FILE_NAME = TEST_FIXTURES['workflows'][0]
WB1_YAML_FILE_PATH = LOADER.get_fixture_file_path_abs(PACK, 'workflows', WB1_YAML_FILE_NAME)
WB1_SPEC = FIXTURES['workflows'][WB1_YAML_FILE_NAME]
WB1_YAML = yaml.safe_dump(WB1_SPEC, default_flow_style=False)
WB1_NAME = '%s.%s' % (PACK, WB1_YAML_FILE_NAME.replace('.yaml', ''))
WB1 = workbooks.Workbook(None, {'name': WB1_NAME, 'definition': WB1_YAML})
WB1_OLD = workbooks.Workbook(None, {'name': WB1_NAME, 'definition': ''})
WB1_EXEC = copy.deepcopy(MISTRAL_EXECUTION)
WB1_EXEC['workflow_name'] = WB1_NAME