|
5 | 5 | import pytest
|
6 | 6 |
|
7 | 7 | from littlepay.commands import RESULT_FAILURE, RESULT_SUCCESS
|
8 |
| -from littlepay.config import CONFIG_TYPES, Config |
| 8 | +from littlepay.config import Config |
9 | 9 | import littlepay.main
|
10 | 10 | from littlepay.main import main, __name__ as MODULE
|
11 | 11 |
|
@@ -270,24 +270,38 @@ def test_main_products_status_unrecognized(mock_commands_products, status_flag):
|
270 | 270 | assert mock_commands_products.call_count == 0
|
271 | 271 |
|
272 | 272 |
|
273 |
| -@pytest.mark.parametrize("switch_type", CONFIG_TYPES) |
274 |
| -def test_main_switch_recognized_type(mock_commands_switch, switch_type): |
275 |
| - result = main(argv=["switch", switch_type, "new_value"]) |
| 273 | +@pytest.mark.parametrize("switch_arg", ["-e", "--env"]) |
| 274 | +def test_main_switch_env(mock_commands_switch, switch_arg): |
| 275 | + result = main(argv=["switch", switch_arg, "new_value"]) |
276 | 276 |
|
277 | 277 | assert result == RESULT_SUCCESS
|
278 |
| - mock_commands_switch.assert_called_once_with(switch_type, "new_value") |
| 278 | + mock_commands_switch.assert_called_once_with("new_value", None) |
279 | 279 |
|
280 | 280 |
|
281 |
| -def test_main_switch_missing_value(mock_commands_switch): |
282 |
| - with pytest.raises(SystemExit): |
283 |
| - main(argv=["switch", "env"]) |
| 281 | +@pytest.mark.parametrize("switch_arg", ["-p", "--participant"]) |
| 282 | +def test_main_switch_participant(mock_commands_switch, switch_arg): |
| 283 | + result = main(argv=["switch", switch_arg, "new_value"]) |
284 | 284 |
|
285 |
| - assert mock_commands_switch.call_count == 0 |
| 285 | + assert result == RESULT_SUCCESS |
| 286 | + mock_commands_switch.assert_called_once_with(None, "new_value") |
| 287 | + |
| 288 | + |
| 289 | +@pytest.mark.parametrize( |
| 290 | + "switch_args", |
| 291 | + [["-e", "env", "-p", "participant"], ["--env", "env", "--participant", "participant"]], |
| 292 | +) |
| 293 | +def test_main_switch_both(mock_commands_switch, switch_args): |
| 294 | + argv = ["switch"] + switch_args |
| 295 | + result = main(argv=argv) |
| 296 | + |
| 297 | + assert result == RESULT_SUCCESS |
| 298 | + mock_commands_switch.assert_called_once_with("env", "participant") |
286 | 299 |
|
287 | 300 |
|
288 |
| -def test_main_switch_unrecognized_type(mock_commands_switch): |
| 301 | +@pytest.mark.parametrize("switch_type", ["-e", "--env", "-p", "--participant"]) |
| 302 | +def test_main_switch_missing_value(mock_commands_switch, switch_type): |
289 | 303 | with pytest.raises(SystemExit):
|
290 |
| - main(argv=["switch", "unrecognized", "new_value"]) |
| 304 | + main(argv=["switch", switch_type]) |
291 | 305 |
|
292 | 306 | assert mock_commands_switch.call_count == 0
|
293 | 307 |
|
|
0 commit comments