Commit 2891474b authored by Christine MARCEL's avatar Christine MARCEL Committed by Samuel GAIST
Browse files

[test][assetwidget] Add missing test for deleting asset in edition

Only the yes condition was tested. Now both use cases
are treated.
parent 07eb4877
...@@ -301,7 +301,10 @@ class TestAssetWidget: ...@@ -301,7 +301,10 @@ class TestAssetWidget:
assert target_name in asset_model.stringList() assert target_name in asset_model.stringList()
assert os.path.exists(asset_model.json_path(target_name)) assert os.path.exists(asset_model.json_path(target_name))
def test_delete( @pytest.mark.parametrize(
"messagebox_answer", [QMessageBox.Yes, QMessageBox.No], ids=["Yes", "No"]
)
def test_delete_asset_in_edition(
self, self,
qtbot, qtbot,
monkeypatch, monkeypatch,
...@@ -309,21 +312,28 @@ class TestAssetWidget: ...@@ -309,21 +312,28 @@ class TestAssetWidget:
beat_context, beat_context,
asset_type, asset_type,
asset_type_prefix_entry_map, asset_type_prefix_entry_map,
messagebox_answer,
): ):
asset_widget = AssetWidget() asset_widget = AssetWidget()
qtbot.addWidget(asset_widget) qtbot.addWidget(asset_widget)
asset_widget.set_context(beat_context) asset_widget.set_context(beat_context)
asset_name = asset_type_prefix_entry_map[asset_type][0] asset_name = asset_type_prefix_entry_map[asset_type][0]
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) monkeypatch.setattr(QMessageBox, "question", lambda *args: messagebox_answer)
asset = Asset(test_prefix, asset_type, asset_name) asset = Asset(test_prefix, asset_type, asset_name)
with qtbot.waitSignal(asset_widget.currentAssetChanged): with qtbot.waitSignal(asset_widget.currentAssetChanged):
asset_widget.loadAsset(asset) asset_widget.loadAsset(asset)
assert asset_widget.current_editor.asset_type != AssetType.UNKNOWN assert asset_widget.current_editor.asset_type != AssetType.UNKNOWN
asset_widget.deleteAsset(asset.declaration_path) asset_widget.deleteAsset(asset.declaration_path)
assert asset_widget.current_editor.asset_type == AssetType.UNKNOWN if messagebox_answer == QMessageBox.Yes:
assert not os.path.exists(asset.declaration_path) assert asset_widget.current_editor.asset_type == AssetType.UNKNOWN
assert not os.path.exists(asset.declaration_path)
else:
assert asset_widget.current_editor.asset_type != AssetType.UNKNOWN
assert asset_widget.current_asset == asset
assert os.path.exists(asset.declaration_path)
def test_load_empty_json( def test_load_empty_json(
self, self,
......
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