Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to mock no connection to server #102

Closed
Amertz08 opened this issue Dec 22, 2015 · 3 comments
Closed

Ability to mock no connection to server #102

Amertz08 opened this issue Dec 22, 2015 · 3 comments

Comments

@Amertz08
Copy link
Contributor

I think it would be useful to mock the errors thrown when you are unable to connect to the redis server. It appears that redis-py throws a ConnectionError with these args ('Error 61 connecting to localhost:6379. Connection refused.',) when it cannot reach the server.

@jamesls
Copy link
Owner

jamesls commented Aug 16, 2016

Seems reasonable. Is someone willing to propose what the API for this would look like?

@Amertz08
Copy link
Contributor Author

Amertz08 commented Aug 16, 2016

class FakeStrictRedis(object):
    CONNECTED = True

    def set(self, *args):
        if not self.CONNECTED:
            raise ConnectionError('Error 61 connecting to localhost:6379. Connection refused.')
        else:
            # proceed as normal

Just an example I guess. Would need to look at the entire redis-py lib

@Amertz08
Copy link
Contributor Author

Amertz08 commented Jan 10, 2018

2 years after the fact I've decided I'd give this a shot. Here is what I have so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants