2

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).

soulshake
  • 780
  • 8
  • 12

1 Answers1

1

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.

Tommaso Barbugli
  • 11,781
  • 2
  • 42
  • 41
  • I had to surround `mymodule.TestFeedManager` in quotes to avoid import issues, but otherwise this is exactly what I was looking for. Thank you! – soulshake Dec 03 '19 at 01:23