Skip to content

Commit

Permalink
Reverse ipts order in the GUI (#140)
Browse files Browse the repository at this point in the history
* Handle missing keys

* Reverse order of IPTS from oncat

* Reverse list of IPTS

* Reverse order of IPTS from oncat

* Reverse list of IPTS

* Rebase from main

* Don't need to reverse the list before being sorted
  • Loading branch information
AndreiSavici authored Aug 30, 2024
1 parent 321c810 commit 8594abb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/shiver/views/oncat.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def update_ipts(self):
)
# update IPTS list
self.ipts.clear()
self.ipts.addItems(sorted(ipts_list, key=lambda x: int(x.split("-")[1])))
self.ipts.addItems(sorted(ipts_list, key=lambda x: int(x.split("-")[1]), reverse=True))

def update_datasets(self):
"""Update dataset list"""
Expand Down
8 changes: 4 additions & 4 deletions tests/views/test_oncat.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def error_message_callback(msg):
# test connect status check
assert oncat.connected_to_oncat is True
# test get_suggested_path
assert oncat.get_suggested_path() == "/SNS/ARCS/IPTS-1111/nexus"
assert oncat.get_suggested_path() == "/SNS/ARCS/IPTS-2222/nexus"
# test get_suggested_selected_files
# case 1: no suggestion
oncat.dataset.setCurrentText("custom")
Expand All @@ -70,12 +70,12 @@ def error_message_callback(msg):
# test active connect to oncat
oncat.connect_to_oncat()
# test as_dict
assert oncat.as_dict() == {"angle_target": 0.1, "dataset": "custom", "instrument": "ARCS", "ipts": "IPTS-1111"}
assert oncat.as_dict() == {"angle_target": 0.1, "dataset": "custom", "instrument": "ARCS", "ipts": "IPTS-2222"}
# test populate from dict
oncat.populate_from_dict({"angle_target": 0.2, "dataset": "custom", "instrument": "HYSPEC", "ipts": "IPTS-1111"})
oncat.populate_from_dict({"angle_target": 0.2, "dataset": "custom", "instrument": "HYSPEC", "ipts": "IPTS-2222"})
assert oncat.angle_target.value() == 0.2
# test get_ipts
assert oncat.get_ipts() == "IPTS-1111"
assert oncat.get_ipts() == "IPTS-2222"
# test get_dataset
assert oncat.get_dataset() == "custom"
# test get_instrument
Expand Down

0 comments on commit 8594abb

Please sign in to comment.