Commit a3362947 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][assetwidget] Fix test for PlotterParameterEditor

parent 2d8ed9c8
......@@ -59,7 +59,7 @@ def asset_type_prefix_entry_map():
),
AssetType.LIBRARY: ("user/sum/1", LibraryEditor),
AssetType.PLOTTER: ("user/scatter/1", PlotterEditor),
AssetType.PLOTTERPARAMETER: ("", PlotterParametersEditor),
AssetType.PLOTTERPARAMETER: ("plot/config/1", PlotterParametersEditor),
AssetType.PROTOCOLTEMPLATE: ("double/1", ProtocolTemplateEditor),
AssetType.TOOLCHAIN: ("user/double/1", ToolchainEditor),
}
......@@ -84,11 +84,10 @@ class TestAssetWidget:
asset_type,
(asset_name, editor_type),
) in asset_type_prefix_entry_map.items():
if asset_name:
asset_widget.load_json(
self.get_asset_path(test_prefix, asset_type, asset_name)
)
assert isinstance(asset_widget.current_editor, editor_type)
asset_widget.load_json(
self.get_asset_path(test_prefix, asset_type, asset_name)
)
assert isinstance(asset_widget.current_editor, editor_type)
def test_dirty(
self, qtbot, monkeypatch, test_prefix, beat_context, asset_type_prefix_entry_map
......@@ -106,25 +105,25 @@ class TestAssetWidget:
asset_type,
(asset_name, editor_type),
) in asset_type_prefix_entry_map.items():
if asset_name:
asset_widget.load_json(
self.get_asset_path(test_prefix, asset_type, asset_name)
asset_widget.load_json(
self.get_asset_path(test_prefix, asset_type, asset_name)
)
assert not asset_widget.current_editor.is_dirty()
with qtbot.waitSignal(asset_widget.json_widget.textChanged):
asset_widget.current_editor.description_lineedit.selectAll()
qtbot.keyClicks(
asset_widget.current_editor.description_lineedit, description
)
assert not asset_widget.current_editor.is_dirty()
with qtbot.waitSignal(asset_widget.json_widget.textChanged):
qtbot.keyClicks(
asset_widget.current_editor.description_lineedit, description
)
assert asset_widget.save_button.isEnabled()
assert asset_widget.current_editor.is_dirty()
assert asset_widget.save_button.isEnabled()
assert asset_widget.current_editor.is_dirty()
dumped_json = asset_widget.current_editor.dump_json()
description_key = "description"
if asset_type == AssetType.DATAFORMAT:
description_key = "#" + description_key
assert dumped_json[description_key] == description
dumped_json = asset_widget.current_editor.dump_json()
description_key = "description"
if asset_type == AssetType.DATAFORMAT:
description_key = "#" + description_key
assert dumped_json[description_key] == description
def test_save(
self, qtbot, monkeypatch, test_prefix, beat_context, asset_type_prefix_entry_map
......@@ -139,22 +138,22 @@ class TestAssetWidget:
asset_type,
(asset_name, editor_type),
) in asset_type_prefix_entry_map.items():
if asset_name:
asset_path = self.get_asset_path(test_prefix, asset_type, asset_name)
asset_widget.load_json(asset_path)
with qtbot.waitSignal(asset_widget.json_widget.textChanged):
qtbot.keyClicks(
asset_widget.current_editor.description_lineedit, description
)
assert asset_widget.save_button.isEnabled()
qtbot.mouseClick(asset_widget.save_button, QtCore.Qt.LeftButton)
assert not asset_widget.save_button.isEnabled()
description_key = "description"
if asset_type == AssetType.DATAFORMAT:
description_key = "#" + description_key
with open(asset_path, "rt") as json_file:
json_data = json.loads(json_file.read())
assert json_data[description_key] == description
asset_path = self.get_asset_path(test_prefix, asset_type, asset_name)
asset_widget.load_json(asset_path)
with qtbot.waitSignal(asset_widget.json_widget.textChanged):
asset_widget.current_editor.description_lineedit.selectAll()
qtbot.keyClicks(
asset_widget.current_editor.description_lineedit, description
)
assert asset_widget.save_button.isEnabled()
qtbot.mouseClick(asset_widget.save_button, QtCore.Qt.LeftButton)
assert not asset_widget.save_button.isEnabled()
description_key = "description"
if asset_type == AssetType.DATAFORMAT:
description_key = "#" + description_key
with open(asset_path, "rt") as json_file:
json_data = json.loads(json_file.read())
assert json_data[description_key] == description
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment