2018-11-22 18:29:57 +00:00
|
|
|
"""
|
|
|
|
This file is part of nucypher.
|
|
|
|
|
|
|
|
nucypher is free software: you can redistribute it and/or modify
|
2019-03-05 02:50:11 +00:00
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
2018-11-22 18:29:57 +00:00
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
nucypher is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-03-05 02:50:11 +00:00
|
|
|
GNU Affero General Public License for more details.
|
2018-11-22 18:29:57 +00:00
|
|
|
|
2019-03-05 02:50:11 +00:00
|
|
|
You should have received a copy of the GNU Affero General Public License
|
2018-11-22 18:29:57 +00:00
|
|
|
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
"""
|
2018-12-02 23:40:46 +00:00
|
|
|
|
|
|
|
|
2018-11-25 20:45:59 +00:00
|
|
|
import contextlib
|
|
|
|
import shutil
|
2018-11-22 18:29:57 +00:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
from click.testing import CliRunner
|
|
|
|
|
2018-11-25 20:45:59 +00:00
|
|
|
from nucypher.config.characters import UrsulaConfiguration
|
2019-02-26 04:46:03 +00:00
|
|
|
from nucypher.utilities.sandbox.constants import MOCK_CUSTOM_INSTALLATION_PATH, MOCK_CUSTOM_INSTALLATION_PATH_2
|
2018-11-25 20:45:59 +00:00
|
|
|
|
2018-11-22 18:29:57 +00:00
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def click_runner():
|
|
|
|
runner = CliRunner()
|
|
|
|
yield runner
|
2018-11-25 20:45:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
2018-12-08 21:06:40 +00:00
|
|
|
def nominal_federated_configuration_fields():
|
|
|
|
config = UrsulaConfiguration(dev_mode=True, federated_only=True)
|
2018-11-25 20:45:59 +00:00
|
|
|
config_fields = config.static_payload
|
|
|
|
del config_fields['is_me']
|
|
|
|
yield tuple(config_fields.keys())
|
|
|
|
del config
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def custom_filepath():
|
|
|
|
_custom_filepath = MOCK_CUSTOM_INSTALLATION_PATH
|
|
|
|
with contextlib.suppress(FileNotFoundError):
|
|
|
|
shutil.rmtree(_custom_filepath, ignore_errors=True)
|
2018-11-25 21:51:20 +00:00
|
|
|
try:
|
|
|
|
yield _custom_filepath
|
|
|
|
finally:
|
|
|
|
with contextlib.suppress(FileNotFoundError):
|
|
|
|
shutil.rmtree(_custom_filepath, ignore_errors=True)
|
2019-02-26 04:46:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def custom_filepath_2():
|
|
|
|
_custom_filepath = MOCK_CUSTOM_INSTALLATION_PATH_2
|
|
|
|
with contextlib.suppress(FileNotFoundError):
|
|
|
|
shutil.rmtree(_custom_filepath, ignore_errors=True)
|
|
|
|
try:
|
|
|
|
yield _custom_filepath
|
|
|
|
finally:
|
|
|
|
with contextlib.suppress(FileNotFoundError):
|
|
|
|
shutil.rmtree(_custom_filepath, ignore_errors=True)
|
|
|
|
|