diff --git a/littlepay/commands/configure.py b/littlepay/commands/configure.py index 46f5f68..dc1cc6b 100644 --- a/littlepay/commands/configure.py +++ b/littlepay/commands/configure.py @@ -4,7 +4,7 @@ from littlepay.config import ENV_PROD, Config -def configure(config_path: str | Path = None, reset: bool = False) -> int: +def configure(config_path: str | Path = None) -> int: """Get or set project configuration. Returns: @@ -12,7 +12,8 @@ def configure(config_path: str | Path = None, reset: bool = False) -> int: """ if config_path is None: config_path = Config.current_path() - config = Config(config_path, reset=reset) + + config = Config(config_path) current_config_path = Config.current_path() env = config.active_env_name() diff --git a/littlepay/config.py b/littlepay/config.py index a09fff5..e6852a0 100644 --- a/littlepay/config.py +++ b/littlepay/config.py @@ -56,19 +56,17 @@ class Config: read = staticmethod(_read_config) write = staticmethod(_write_config) - def __init__(self, config_file_path: str | Path = None, reset: bool = False): + def __init__(self, config_file_path: str | Path = None): """Initialize a new Config instance, reading from the given path or a default location. Args: config_file_path (str|Path): Path to a readable config file. If None, the default is used. - - reset (bool): True to reset the configuration to the default. """ if config_file_path is None or config_file_path == "": config_file_path = Config.current_path() if isinstance(config_file_path, str): config_file_path = Path(config_file_path) - if not config_file_path.exists() or reset: + if not config_file_path.exists(): print(f"Creating config file: {config_file_path.resolve()}") config_file_path.parent.mkdir(parents=True, exist_ok=True) Config.write(DEFAULT_CONFIG, config_file_path) diff --git a/littlepay/main.py b/littlepay/main.py index 036d4fe..9f52214 100644 --- a/littlepay/main.py +++ b/littlepay/main.py @@ -34,7 +34,6 @@ def _subcmd(name, help) -> argparse.ArgumentParser: dest="config_path", help="Path to a readable and writeable config file to use. File will be created if it does not exist.", ) - config_parser.add_argument("--reset", action="store_true", default=False, help="Reset the configuration.") switch_parser = _subcmd("switch", help="Switch the active environment or participant.") switch_parser.add_argument("switch_type", choices=CONFIG_TYPES, help="The type of object to switch", metavar="TYPE") @@ -46,7 +45,7 @@ def _subcmd(name, help) -> argparse.ArgumentParser: args = parser.parse_args(argv) if args.command == "config": - return configure(args.config_path, args.reset) + return configure(args.config_path) elif args.command == "switch": return switch(args.switch_type, args.switch_arg) diff --git a/tests/commands/test_configure.py b/tests/commands/test_configure.py index 455f3ce..b17b77a 100644 --- a/tests/commands/test_configure.py +++ b/tests/commands/test_configure.py @@ -1,5 +1,3 @@ -from pathlib import Path - import pytest from littlepay.commands import RESULT_FAILURE, RESULT_SUCCESS @@ -99,16 +97,3 @@ def test_configure_participant_credentials_prod(mock_Config, capfd): assert res == RESULT_SUCCESS assert "Active: ⚠️ prod, participant123" in capture.out assert "[missing credentials]" not in capture.out - - -def test_configure_reset(custom_config_file: Path): - content = "Custom config content written here" - custom_config_file.write_text(content) - assert custom_config_file.exists() - assert content in custom_config_file.read_text() - - res = configure(custom_config_file, reset=True) - - assert res == RESULT_FAILURE - assert custom_config_file.exists() - assert content not in custom_config_file.read_text() diff --git a/tests/test_config.py b/tests/test_config.py index d2a9d8b..66c3ed0 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -104,20 +104,6 @@ def test_Config_exists(custom_config_file: Path): assert config.other_data == "more config" -def test_Config_reset(custom_config_file: Path): - assert not custom_config_file.exists() - custom_config_file.write_text('{"data": "the config"}') - assert custom_config_file.exists() - - config = Config(custom_config_file, reset=True) - - assert custom_config_file.exists() - assert config.active == DEFAULT_CONFIG["active"] - assert config.envs == DEFAULT_CONFIG["envs"] - assert config.participants == DEFAULT_CONFIG["participants"] - assert not hasattr(config, "data") - - def test_Config_active_env_name(mocker): config = Config() config.active = mocker.Mock()