Release 0.0.1
See README diff for changes
This commit is contained in:
parent
6633423420
commit
4e6801e4d8
39 changed files with 917 additions and 443 deletions
pappyproxy/tests
42
pappyproxy/tests/testutil.py
Normal file
42
pappyproxy/tests/testutil.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
from twisted.internet import defer
|
||||
|
||||
class ClassDeleted():
|
||||
pass
|
||||
|
||||
def func_deleted(*args, **kwargs):
|
||||
raise NotImplementedError()
|
||||
|
||||
def func_ignored(*args, **kwargs):
|
||||
pass
|
||||
|
||||
def func_ignored_deferred(*args, **kwargs):
|
||||
return mock_deferred(None)
|
||||
|
||||
def mock_deferred(value):
|
||||
# Generates a function that can be used to make a deferred that can be used
|
||||
# to mock out deferred-returning responses
|
||||
def g(data):
|
||||
return value
|
||||
d = defer.Deferred()
|
||||
d.addCallback(g)
|
||||
d.callback(None)
|
||||
return d
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def no_tcp(mocker):
|
||||
# Don't make tcp connections
|
||||
mocker.patch("twisted.internet.reactor.connectTCP", new=func_deleted)
|
||||
mocker.patch("twisted.internet.reactor.connectSSL", new=func_deleted)
|
||||
|
||||
@pytest.fixture
|
||||
def ignore_tcp(mocker):
|
||||
# Don't make tcp connections
|
||||
mocker.patch("twisted.internet.reactor.connectTCP", new=func_ignored)
|
||||
mocker.patch("twisted.internet.reactor.connectSSL", new=func_ignored)
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def no_database(mocker):
|
||||
# Don't make database queries
|
||||
mocker.patch("twisted.enterprise.adbapi.ConnectionPool",
|
||||
new=ClassDeleted)
|
Loading…
Add table
Add a link
Reference in a new issue