How to disable Stream in Django

108 views Asked by At

I am trying to temporarily prevent stream_django from making any remote API calls for offline development and testing purposes.

What is the easiest way to completely disable remote connections to the upstream API servers?

I found feed_manager.disable_model_tracking() which seems to prevent Activity updates, but it doesn't prevent all upstream calls (feed_manager.follow_user() for example).

1

There are 1 answers

1
Tommaso Barbugli On BEST ANSWER

stream_django allows you to use a custom feed manager class via the STREAM_FEED_MANAGER_CLASS Django setting; that's probably the simplest way to skip follow/unfollow requests.

# yoursettings.py
STREAM_FEED_MANAGER_CLASS = "mymodule.TestFeedManager"

# mymodule/__init__.py
from stream_django import managers

class TestFeedManager(managers.FeedManager):

    def follow_user(self, *args, **kwargs):
        pass

    def unfollow_user(self, *args, **kwargs):
        pass

Another approach, perhaps more powerful (and complex) is to use the mock library to stub the manager or similar approach.