Пример #1
0
    def setUp(self):
        created = ActionExecutionDB()
        created.action = {'uid': 'action:core:ask'}
        created.status = 'succeeded'
        created.runner = {'name': 'inquirer'}
        created.liveaction = INQUIRY_LIVEACTION
        created.result = INQUIRY_RESULT

        self.saved = ActionExecutionModelTest._save_execution(created)
        self.retrieved = ActionExecution.get_by_id(self.saved.id)
        self.assertEqual(self.saved.action, self.retrieved.action,
                         'Same action was not returned.')
Пример #2
0
    def setUp(self):

        self.executions = {}

        for name, execution in ACTIONEXECUTIONS.items():

            created = ActionExecutionDB()
            created.action = execution['action']
            created.status = execution['status']
            created.runner = execution['runner']
            created.liveaction = execution['liveaction']
            created.result = execution['result']

            saved = ActionExecutionModelTest._save_execution(created)
            retrieved = ActionExecution.get_by_id(saved.id)
            self.assertEqual(saved.action, retrieved.action,
                             'Same action was not returned.')

            self.executions[name] = retrieved
Пример #3
0
    def setUp(self):

        self.executions = {}

        for name, execution in ACTIONEXECUTIONS.items():

            created = ActionExecutionDB()
            created.action = execution['action']
            created.status = execution['status']
            created.runner = execution['runner']
            created.liveaction = execution['liveaction']
            created.result = execution['result']

            saved = ActionExecutionModelTest._save_execution(created)
            retrieved = ActionExecution.get_by_id(saved.id)
            self.assertEqual(saved.action, retrieved.action,
                             'Same action was not returned.')

            self.executions[name] = retrieved
Пример #4
0
    },
    "k6": [1, 3],
}

MOCK_TRIGGER_INSTANCE_4 = TriggerInstanceDB()
MOCK_TRIGGER_INSTANCE_4.id = "triggerinstance-test4"
MOCK_TRIGGER_INSTANCE_4.payload = MOCK_TRIGGER_INSTANCE_PAYLOAD
MOCK_TRIGGER_INSTANCE_4.occurrence_time = date_utils.get_datetime_utc_now()

MOCK_LIVEACTION = LiveActionDB()
MOCK_LIVEACTION.id = "liveaction-test-1.id"
MOCK_LIVEACTION.status = "requested"

MOCK_EXECUTION = ActionExecutionDB()
MOCK_EXECUTION.id = "exec-test-1.id"
MOCK_EXECUTION.status = "requested"

FAILURE_REASON = "fail!"


class BaseRuleEnforcerTestCase(DbTestCase):

    models = None

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

        runners_registrar.register_runners()

        # Create TriggerTypes before creation of Rule to avoid failure. Rule requires the
Пример #5
0
MOCK_TRIGGER_INSTANCE_2.id = 'triggerinstance-test2'
MOCK_TRIGGER_INSTANCE_2.payload = {'t1_p': None}
MOCK_TRIGGER_INSTANCE_2.occurrence_time = date_utils.get_datetime_utc_now()

MOCK_TRIGGER_INSTANCE_3 = TriggerInstanceDB()
MOCK_TRIGGER_INSTANCE_3.id = 'triggerinstance-test3'
MOCK_TRIGGER_INSTANCE_3.payload = {'t1_p': None, 't2_p': 'value2'}
MOCK_TRIGGER_INSTANCE_3.occurrence_time = date_utils.get_datetime_utc_now()

MOCK_LIVEACTION = LiveActionDB()
MOCK_LIVEACTION.id = 'liveaction-test-1.id'
MOCK_LIVEACTION.status = 'requested'

MOCK_EXECUTION = ActionExecutionDB()
MOCK_EXECUTION.id = 'exec-test-1.id'
MOCK_EXECUTION.status = 'requested'

FAILURE_REASON = "fail!"


class EnforceTest(DbTestCase):

    models = None

    @classmethod
    def setUpClass(cls):
        super(EnforceTest, cls).setUpClass()
        # 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_1)
Пример #6
0
MOCK_TRIGGER_INSTANCE_2.id = 'triggerinstance-test2'
MOCK_TRIGGER_INSTANCE_2.payload = {'t1_p': None}
MOCK_TRIGGER_INSTANCE_2.occurrence_time = date_utils.get_datetime_utc_now()

MOCK_TRIGGER_INSTANCE_3 = TriggerInstanceDB()
MOCK_TRIGGER_INSTANCE_3.id = 'triggerinstance-test3'
MOCK_TRIGGER_INSTANCE_3.payload = {'t1_p': None, 't2_p': 'value2'}
MOCK_TRIGGER_INSTANCE_3.occurrence_time = date_utils.get_datetime_utc_now()

MOCK_LIVEACTION = LiveActionDB()
MOCK_LIVEACTION.id = 'liveaction-test-1.id'
MOCK_LIVEACTION.status = 'requested'

MOCK_EXECUTION = ActionExecutionDB()
MOCK_EXECUTION.id = 'exec-test-1.id'
MOCK_EXECUTION.status = 'requested'

FAILURE_REASON = "fail!"


class EnforceTest(DbTestCase):

    models = None

    @classmethod
    def setUpClass(cls):
        super(EnforceTest, cls).setUpClass()
        # 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_1)