<commit_before>import copy
import datetime

import mock

from st2common.exceptions.db import StackStormDBObjectNotFoundError
from st2common.transport.publishers import PoolPublisher
from st2common.models.api.action import RunnerTypeAPI
from st2common.models.db.action import (ActionDB, ActionExecutionDB)
from st2common.persistence.action import (Action, ActionExecution, RunnerType)
import st2common.util.action_db as action_db_utils
from st2tests.base import DbTestCase


@mock.patch.object(PoolPublisher, 'publish', mock.MagicMock())
class ActionDBUtilsTestCase(DbTestCase):
    runnertype_db = None
    action_db = None
    actionexec_db = None

    @classmethod
    def setUpClass(cls):
        super(DbTestCase, cls).setUpClass()
        ActionDBUtilsTestCase._setup_test_models()

    def test_get_runnertype_nonexisting(self):
        # By id.
        self.assertRaises(StackStormDBObjectNotFoundError, action_db_utils.get_runnertype_by_id,
                          'somedummyrunnerid')
        # By name.
        self.assertRaises(StackStormDBObjectNotFoundError, action_db_utils.get_runnertype_by_name,<commit_msg>Fix class reference in super call.<commit_after>import copy
import datetime

import mock

from st2common.exceptions.db import StackStormDBObjectNotFoundError
from st2common.transport.publishers import PoolPublisher
from st2common.models.api.action import RunnerTypeAPI
from st2common.models.db.action import (ActionDB, ActionExecutionDB)
from st2common.persistence.action import (Action, ActionExecution, RunnerType)
import st2common.util.action_db as action_db_utils
from st2tests.base import DbTestCase


@mock.patch.object(PoolPublisher, 'publish', mock.MagicMock())
class ActionDBUtilsTestCase(DbTestCase):
    runnertype_db = None
    action_db = None
    actionexec_db = None

    @classmethod
    def setUpClass(cls):
        super(ActionDBUtilsTestCase, cls).setUpClass()
        ActionDBUtilsTestCase._setup_test_models()

    def test_get_runnertype_nonexisting(self):
        # By id.
        self.assertRaises(StackStormDBObjectNotFoundError, action_db_utils.get_runnertype_by_id,
                          'somedummyrunnerid')
        # By name.
        self.assertRaises(StackStormDBObjectNotFoundError, action_db_utils.get_runnertype_by_name,
{'fraction_non_alphanumeric': 0.06704645048203331, 'fraction_numerical': 0.006134969325153374, 'mean_word_length': 4.637037037037037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7544268', 'n_tokens_mistral': 702, 'n_tokens_neox': 669, 'n_words': 134}