mirror of https://github.com/nucypher/nucypher.git
localizes card mocking fixture so CLI test modules will propery run.
parent
a9d3b6cf1e
commit
5b88afc7c6
|
@ -18,12 +18,25 @@
|
|||
|
||||
import os
|
||||
import pytest
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from umbral.keys import UmbralPrivateKey
|
||||
|
||||
from nucypher.cli.main import nucypher_cli
|
||||
from nucypher.policy.identity import Card
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def patch_card_directory(session_mocker):
|
||||
custom_filepath = '/tmp/nucypher-test-cards-'
|
||||
tmpdir = tempfile.TemporaryDirectory(prefix=custom_filepath)
|
||||
tmpdir.cleanup()
|
||||
session_mocker.patch.object(Card, 'CARD_DIR', return_value=Path(tmpdir.name),
|
||||
new_callable=session_mocker.PropertyMock)
|
||||
yield
|
||||
tmpdir.cleanup()
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def alice_verifying_key():
|
||||
return UmbralPrivateKey.gen_key().get_pubkey().hex()
|
||||
|
|
|
@ -15,19 +15,15 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
import lmdb
|
||||
import pytest
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from nucypher.characters.control.emitters import WebEmitter
|
||||
from nucypher.crypto.powers import TransactingPower
|
||||
from nucypher.network.nodes import Learner
|
||||
from nucypher.network.trackers import AvailabilityTracker
|
||||
from nucypher.policy.identity import Card
|
||||
from nucypher.utilities.logging import GlobalLoggerSettings
|
||||
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD
|
||||
from tests.mock.datastore import mock_lmdb_open
|
||||
|
@ -192,17 +188,6 @@ def check_character_state_after_test(request):
|
|||
tracker.work_tracker.stop()
|
||||
|
||||
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def patch_card_directory(session_mocker):
|
||||
custom_filepath = '/tmp/nucypher-test-cards-'
|
||||
tmpdir = tempfile.TemporaryDirectory(prefix=custom_filepath)
|
||||
tmpdir.cleanup()
|
||||
session_mocker.patch.object(Card, 'CARD_DIR', return_value=Path(tmpdir.name),
|
||||
new_callable=session_mocker.PropertyMock)
|
||||
yield
|
||||
tmpdir.cleanup()
|
||||
|
||||
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def mock_datastore(monkeysession):
|
||||
monkeysession.setattr(lmdb, 'open', mock_lmdb_open)
|
||||
|
|
Loading…
Reference in New Issue