Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/fixate/core/config_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
34 changes: 34 additions & 0 deletions test/core/test_config_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Loading