From 7deab1242dcf08c50cb0a7b070eb10527ff1fc31 Mon Sep 17 00:00:00 2001 From: jMyles Date: Tue, 21 Apr 2020 10:38:25 -0700 Subject: [PATCH] Mocking one layer out (setting policy) for these tests. --- .../learning/test_discovery_phases.py | 33 +++++++++++-------- tests/mock/performance_mocks.py | 4 +++ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/tests/integration/learning/test_discovery_phases.py b/tests/integration/learning/test_discovery_phases.py index 619dc690e..8e8cec45e 100644 --- a/tests/integration/learning/test_discovery_phases.py +++ b/tests/integration/learning/test_discovery_phases.py @@ -97,20 +97,25 @@ def test_alice_verifies_ursula_just_in_time(fleet_of_highperf_mocked_ursulas, hi def mock_set_policy(id_as_hex): return "" - def mock_receive_treasure_map(treasure_map_id): - return Response(bytes(), status=202) - - with NotARestApp.replace_route("receive_treasure_map", mock_receive_treasure_map): - with NotARestApp.replace_route("set_policy", mock_set_policy): - with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True): - with patch('umbral.keys.UmbralPublicKey.from_bytes', - new=actual_random_key_instead): - with mock_cert_loading, mock_metadata_validation, mock_message_verification: - with mock_secret_source(): - policy = highperf_mocked_alice.grant( - highperf_mocked_bob, b"any label", m=20, n=30, - expiration=maya.when('next week'), - publish_treasure_map=False) + with NotARestApp.replace_route("set_policy", mock_set_policy): + with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True): + with patch('umbral.keys.UmbralPublicKey.from_bytes', + new=actual_random_key_instead): + with mock_cert_loading, mock_metadata_validation, mock_message_verification: + with mock_secret_source(): + policy = highperf_mocked_alice.grant( + highperf_mocked_bob, b"any label", m=20, n=30, + expiration=maya.when('next week'), + publish_treasure_map=False) # TODO: Make some assertions about policy. total_verified = sum(node.verified_node for node in highperf_mocked_alice.known_nodes) assert total_verified == 30 + + with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True), mock_metadata_validation: + try: + policy.publish_treasure_map(network_middleware=highperf_mocked_alice.network_middleware) + except Exception as e: + raise + +def test_mass_treasure_map_placement(highperf_mocked_alice): + assert False \ No newline at end of file diff --git a/tests/mock/performance_mocks.py b/tests/mock/performance_mocks.py index 59fde483d..dc8b72b53 100644 --- a/tests/mock/performance_mocks.py +++ b/tests/mock/performance_mocks.py @@ -399,6 +399,10 @@ class NotAPublicKey: self.__dict__ = _umbral_pubkey.__dict__ self.__class__ = _umbral_pubkey.__class__ + def to_cryptography_pubkey(self): + self.i_want_to_be_a_real_boy() + return self.to_cryptography_pubkey() + @property def params(self): # Holy heck, metamock hacking.