Django testing disable app and middle ware to test multiple databases setup with only one testing database

27 views Asked by At

I am using multiple databases where in a special case I am streaming data into a warehouse (by using signals). However, for testing the business logic I don't want to stream warehouse data so I want to disable this app and middleware. But something is wrong since the test still requires multiple database settings:

@override_settings(REST_FRAMEWORK={"PAGE_SIZE": 2})
@modify_settings(MIDDLEWARE={'remove': ['dwhstreaming.middleware.LoggingStackMiddleware']}, INSTALLED_APPS={'remove': ['dwhstreaming']})
class TestAPI(TokenAuthenticatedTestAPI):

    # Test works fine if I add these:
    # multi_db = True
    # databases = {'default', 'dwh-stream'}


    def test_create_client(self):
        client = deepcopy(SAMPLE_CLIENT)
        # do something ...

Fails with: Database queries to 'dwh-stream' are not allowed in this test

0

There are 0 answers