mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-22 13:20:38 +08:00
fix by review
This commit is contained in:
@@ -228,7 +228,7 @@ class APITestCase(TestCase):
|
||||
self.assertEqual(status, 204)
|
||||
histories = serialize_preference_history(storage.get_study_system_attrs(study_id))
|
||||
assert len(histories) == 1
|
||||
assert histories[0]["enabled"]
|
||||
assert not histories[0]["is_removed"]
|
||||
|
||||
history_id = histories[0]["id"]
|
||||
status, _, _ = send_request(
|
||||
@@ -240,7 +240,7 @@ class APITestCase(TestCase):
|
||||
self.assertEqual(status, 204)
|
||||
histories = serialize_preference_history(storage.get_study_system_attrs(study_id))
|
||||
assert len(histories) == 1
|
||||
assert not histories[0]["enabled"]
|
||||
assert histories[0]["is_removed"]
|
||||
assert len(study.get_preferences()) == 0
|
||||
|
||||
status, _, _ = send_request(
|
||||
@@ -252,7 +252,7 @@ class APITestCase(TestCase):
|
||||
self.assertEqual(status, 204)
|
||||
histories = serialize_preference_history(storage.get_study_system_attrs(study_id))
|
||||
assert len(histories) == 1
|
||||
assert histories[0]["enabled"]
|
||||
assert not histories[0]["is_removed"]
|
||||
preferences = study.get_preferences()
|
||||
preferences.sort(key=lambda x: (x[0].number, x[1].number))
|
||||
assert len(preferences) == 2
|
||||
|
||||
@@ -46,7 +46,7 @@ def test_report_and_get_choices(storage_supplier: Callable[[], StorageSupplier])
|
||||
assert len(history) == 2
|
||||
assert history[0]["candidates"] == [0, 1, 2]
|
||||
assert history[0]["clicked"] == 1
|
||||
preferences = sys_attrs[_SYSTEM_ATTR_PREFIX_PREFERENCE + history[0]["preference_id"]]
|
||||
preferences = sys_attrs[_SYSTEM_ATTR_PREFIX_PREFERENCE + history[0]["id"]]
|
||||
assert len(preferences) == 2
|
||||
for i, (best, worst) in enumerate([(0, 1), (2, 1)]):
|
||||
assert len(preferences[i]) == 2
|
||||
@@ -54,7 +54,7 @@ def test_report_and_get_choices(storage_supplier: Callable[[], StorageSupplier])
|
||||
assert preferences[i][1] == worst
|
||||
assert history[1]["candidates"] == [0, 2, 3, 4]
|
||||
assert history[1]["clicked"] == 0
|
||||
preferences = sys_attrs[_SYSTEM_ATTR_PREFIX_PREFERENCE + history[1]["preference_id"]]
|
||||
preferences = sys_attrs[_SYSTEM_ATTR_PREFIX_PREFERENCE + history[1]["id"]]
|
||||
assert len(preferences) == 3
|
||||
for i, (best, worst) in enumerate([(2, 0), (3, 0), (4, 0)]):
|
||||
assert len(preferences[i]) == 2
|
||||
@@ -72,13 +72,11 @@ def test_undo_redo_history(storage_supplier: Callable[[], StorageSupplier]) -> N
|
||||
|
||||
study_id = study._study._study_id
|
||||
|
||||
def get_preferences_history(history_id: str) -> tuple[list[tuple[int, int]], History]:
|
||||
def get_preferences_history(id: str) -> tuple[list[tuple[int, int]], History]:
|
||||
system_attrs = storage.get_study_system_attrs(study_id)
|
||||
history: History = json.loads(
|
||||
system_attrs.get(_SYSTEM_ATTR_PREFIX_HISTORY + history_id, "")
|
||||
)
|
||||
history: History = json.loads(system_attrs.get(_SYSTEM_ATTR_PREFIX_HISTORY + id, ""))
|
||||
preference: list[tuple[int, int]] = system_attrs.get(
|
||||
_SYSTEM_ATTR_PREFIX_PREFERENCE + history["preference_id"], []
|
||||
_SYSTEM_ATTR_PREFIX_PREFERENCE + id, []
|
||||
)
|
||||
return preference, history
|
||||
|
||||
|
||||
Reference in New Issue
Block a user