txamqp-dev team mailing list archive
-
txamqp-dev team
-
Mailing list archive
-
Message #00024
mocking responses in unit tests
Part of our test case looks like this. Notice the fake out of the
Method response below? It took some time to discover it by
inspection. Is there an easier way to mock the response stuff from
the middleware?
method = FakeMethod()
msg = Message(method, {}, content)
msg.delivery_tag = 'abc'
chan = FakeChannel()
protocol._dispatchMessage(msg, chan)
self.assertTrue(...
# Grossly fake out some nasty amqp guts.
class FakeFields:
class bypyname:
def __getitem__(self, name):
return name
bypyname = bypyname()
def __getitem__(self, key):
return key
def index(self, name):
return name
class FakeMethod:
def __init__(self):
self.fields = FakeFields()
class FakeChannel:
def basic_ack(self, *a, **kw):
pass
-Nate