diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 345d628b..aa0a667c 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -28,6 +28,7 @@ Improvements now be called after performing signal acquisition. - Invert channel and vtime functions implemented in the DSO driver. - Fxconfig fixes for cmd2 4.0.0 +- Added aliases for "quit" and "open" commands in fxconfig. ************* Version 0.6.4 diff --git a/src/fixate/core/config_util.py b/src/fixate/core/config_util.py index ea7b85d2..747bfc40 100644 --- a/src/fixate/core/config_util.py +++ b/src/fixate/core/config_util.py @@ -347,6 +347,15 @@ def _test_config_dict(self, config_dict): self.pfeedback(f"{new_id} || {idn}") self._test_print_error(port, "ID query does not match") + def do_load(self, line): + """Alias for open command""" + self.do_open(line) + + def do_exit(self, line): + """Exit the application.""" + # cmd2 already has the 'quit' command built in, so this is mostly an alias. + return True + # Stolen from discover.py. This should probably get consolidated back there, # but I want to avoid messing with the internals for now. diff --git a/test/core/test_config_util.py b/test/core/test_config_util.py index d3690190..f06a485f 100644 --- a/test/core/test_config_util.py +++ b/test/core/test_config_util.py @@ -32,6 +32,10 @@ def test_open_fxconfig_no_file(test_app, monkeypatch): test_app.do_open("") assert test_app.config_file_path is None assert test_app.updated_config_dict is None + # ensure the alias also works. + test_app.do_load("") + assert test_app.config_file_path is None + assert test_app.updated_config_dict is None def test_new_config_file_default(test_app, monkeypatch, tmp_path): @@ -83,6 +87,32 @@ def test_open_fxconfig(test_app): } +def test_load_fxconfig(test_app): + test_app.do_load("test/config/instruments.json") + assert test_app.config_file_path == "test/config/instruments.json" + assert test_app.updated_config_dict == { + "INSTRUMENTS": { + "visa": [ + [ + "RIGOL TECHNOLOGIES,DG1022 ,DG1D144904270,,00.03.00.09.00.02.11\n", + "USB0::0x09C4::0x0400::DG1D144904270::INSTR", + ], + ["FLUKE,8846A,3821015,08/02/10-11:53\r\n", "ASRL38::INSTR"], + [ + "AGILENT TECHNOLOGIES,MSO-X 3014A,MY52160892,02.41.2015102200", + "USB0::0x0957::0x17A8::MY52160892::INSTR", + ], + ], + "serial": { + "COM37": [ + "address: 0,checksum: 28,command: 49,model: 6823,serial_number: 3697210019,software_version: 29440,start: 170,", + 9600, + ] + }, + } + } + + # testing the _add_visa_to_config method directly since there is too much reliance on the ResourceManager # which would need to be monkeypatched or mocked. def test_add_visa_to_config_duplicate(test_app, open_config_file): @@ -136,3 +166,7 @@ def test_do_save_same_path_backup_created(test_app, open_config_file, tmp_path): test_app.do_save(tmp_path / "instruments.json") # ensure backup file is created assert (tmp_path / "instruments.json.bak").exists() + + +def test_do_exit(test_app): + assert test_app.do_exit("") is True