Commit 65c874fb authored by Flavio TARSETTI's avatar Flavio TARSETTI Committed by Samuel GAIST
Browse files

[test][toolchaineditor] adding tests for BlockType class

Fixes #256
parent b0838f78
Pipeline #38377 passed with stage
in 6 minutes and 16 seconds
......@@ -37,6 +37,7 @@ from ..backend.assetmodel import AssetModel
from ..widgets.toolchaineditor import ToolchainEditor
from ..widgets.toolchaineditor import ToolchainView
from ..widgets.toolchaineditor import BlockType
from ..widgets.toolchainscene import ToolchainScene
from .conftest import sync_prefix
......@@ -73,6 +74,14 @@ def get_valid_toolchains(test_prefix):
def get_valid_block_types():
return ["datasets", "blocks", "analyzers", "loops"]
def get_invalid_block_types():
return ["invalid_1", "invalid_2"]
class TestToolchainScene:
def test_good_init(self, qtbot, scene_config):
scene = ToolchainScene(scene_config)
......@@ -120,6 +129,34 @@ class TestToolchainScene:
assert isinstance(scene, QGraphicsScene)
class TestBlockType:
"""Test the BlockType enum class"""
@pytest.mark.parametrize("block_type", get_valid_block_types())
def test_valid_block_type(self, qtbot, block_type):
block_type_name = block_type.upper()
assert any([block_type_name == for type_ in BlockType])
@pytest.mark.parametrize("block_type", get_invalid_block_types())
def test_invalid_block_type(self, qtbot, block_type):
block_type_name = block_type.upper()
assert not any([block_type_name == for type_ in BlockType])
@pytest.mark.parametrize("block_type", get_valid_block_types())
def test_valid_block_type_from_name(self, qtbot, block_type):
name = block_type.upper()
created_block_type = BlockType.from_name(name)
assert isinstance(created_block_type, BlockType)
assert == name
@pytest.mark.parametrize("block_type", get_invalid_block_types())
def test_invalid_block_type_from_name(self, qtbot, block_type):
name = block_type.upper()
with pytest.raises(KeyError) as excinfo:
assert "{} is not a valid block type".format(name) in str(excinfo.value)
class TestToolchainEditor:
"""Test that the mock editor works correctly"""
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