示例#1
0
    def test_monkey_patch_test_db(self, mock_method):
        monkey_patch_test_db()

        creation = BaseDatabaseCreation(None)
        creation.create_test_db()
        creation.destroy_test_db('foo_db')

        mock_method.assert_called_once_with(None)
示例#2
0
    def test_monkey_patch_test_db(self, mock_method):
        monkey_patch_test_db()

        creation = BaseDatabaseCreation(None)
        creation.create_test_db()
        creation.destroy_test_db('foo_db')

        mock_method.assert_called_once_with(None)
示例#3
0
from django.db.utils import ConnectionHandler
from mock import MagicMock

import django.core.management.commands.loaddata
from django.db.utils import NotSupportedError
from django_mock_queries.mocks import monkey_patch_test_db
import django_mock_queries.mocks

# noinspection PyUnresolvedReferences
from kive.settings import *

monkey_patch_test_db()

django.core.management.commands.loaddata.Command.handle = lambda *args, **kwargs: None

original_mock_django_connection = django_mock_queries.mocks.mock_django_connection


# Patch for django_mock_queries until a PR is merged.
def patched_mock_django_connection(disabled_features=None):
    original_mock_django_connection(disabled_features=disabled_features)

    # noinspection PyUnusedLocal
    def patched_compiler(queryset, connection, using, **kwargs):
        result = MagicMock(name='mock_connection.ops.compiler()')
        # noinspection PyProtectedMember
        result.execute_sql.side_effect = NotSupportedError(
            "Mock database tried to execute SQL for {} model.".format(
                queryset.model._meta.object_name))
        result.has_results.side_effect = result.execute_sql.side_effect
        return result
示例#4
0
from django_mock_queries.mocks import monkey_patch_test_db

from .common import *

class Test(Common):
    pass

monkey_patch_test_db()