fully subclass the client for testing purposes.

pull/730/head
jMyles 2019-02-04 22:32:18 -05:00
parent f96af2d050
commit 0fdd62cba7
1 changed files with 12 additions and 4 deletions

View File

@ -16,20 +16,28 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
from bytestring_splitter import VariableLengthBytestring
from nucypher.characters.lawful import Ursula
from nucypher.network.middleware import RestMiddleware
from nucypher.network.middleware import RestMiddleware, NucypherMiddlewareClient
from nucypher.utilities.sandbox.constants import MOCK_KNOWN_URSULAS_CACHE
class _TestMiddlewareClient(NucypherMiddlewareClient):
def node_selector(self, node):
assert False
class MockRestMiddleware(RestMiddleware):
_ursulas = None
class NotEnoughMockUrsulas(Ursula.NotEnoughUrsulas):
pass
@staticmethod
def response_cleaner(self, response):
response.content = response.data
return response
client = _TestMiddlewareClient(response_cleaner=response_cleaner)
class NotEnoughMockUrsulas(Ursula.NotEnoughUrsulas):
pass
def _get_mock_client_by_ursula(self, ursula):
port = ursula.rest_information()[0].port
return self._get_mock_client_by_port(port)