make_federated_ursulas gets called from a few places of varying depths in the stack - accounting for that.

pull/2175/head
jMyles 2020-07-24 16:00:19 -07:00
parent 924435ee37
commit 5fd14a7109
3 changed files with 15 additions and 5 deletions

View File

@ -27,8 +27,6 @@ from nucypher.crypto.powers import (CryptoPower, NoSigningPower, SigningPower)
"""
Chapter 1: SIGNING
"""
def test_actor_without_signing_power_cannot_sign():
"""
We can create a Character with no real CryptoPower to speak of.

View File

@ -52,10 +52,11 @@ class _TestMiddlewareClient(NucypherMiddlewareClient):
return mock_client
def _get_ursula_by_port(self, port):
mkuc = MOCK_KNOWN_URSULAS_CACHE
try:
return MOCK_KNOWN_URSULAS_CACHE[port]
return mkuc[port]
except KeyError:
raise RuntimeError(
raise RuntimeError(
"Can't find an Ursula with port {} - did you spin up the right test ursulas?".format(port))
def parse_node_or_host_and_port(self, node=None, host=None, port=None):

View File

@ -68,13 +68,24 @@ def make_federated_ursulas(ursula_config: UrsulaConfiguration,
federated_ursulas = set()
frames = inspect.stack(3)
# This gets called from various places.
for frame in range(1, 10):
try:
test_name = frames[frame].frame.f_locals['request'].module
break
except KeyError:
continue
for port in range(starting_port, starting_port+quantity):
ursula = ursula_config.produce(rest_port=port + 100,
db_filepath=MOCK_URSULA_DB_FILEPATH,
**ursula_overrides)
ursula._FOR_TEST = frames[1].frame.f_locals['request'].module
try:
ursula._FOR_TEST = test_name
except UnboundLocalError:
raise RuntimeError("Unable to find a test name to assign to this ursula in the first 10 frames.")
federated_ursulas.add(ursula)
# Store this Ursula in our global testing cache.