From 66a5a856c0f495f4bc495bb0dd63366d9eeec9f5 Mon Sep 17 00:00:00 2001 From: AlexandreSajus Date: Wed, 8 Dec 2021 18:50:23 +0100 Subject: [PATCH 1/5] :umbrella: adds non functional flow test --- tests/assets/flow_test.ipyg | 865 ++++++++++++++++++++++++++ tests/integration/blocks/test_flow.py | 55 ++ 2 files changed, 920 insertions(+) create mode 100644 tests/assets/flow_test.ipyg create mode 100644 tests/integration/blocks/test_flow.py diff --git a/tests/assets/flow_test.ipyg b/tests/assets/flow_test.ipyg new file mode 100644 index 00000000..0a20333b --- /dev/null +++ b/tests/assets/flow_test.ipyg @@ -0,0 +1,865 @@ +{ + "id": 2047380826296, + "blocks": [ + { + "id": 2047380828024, + "title": "Test flow 5", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 203, + 0 + ], + "position": [ + 126.0, + -202.0 + ], + "width": 316, + "height": 256, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047509615672, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047509615816, + "type": "output", + "position": [ + 316.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "d = 4\r\na + b + c", + "stdout": "" + }, + { + "id": 2047509975832, + "title": "Test flow 1", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 187, + 0 + ], + "position": [ + -616.0, + -200.0 + ], + "width": 302, + "height": 240, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047509976840, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047509976984, + "type": "output", + "position": [ + 302.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "a = 1", + "stdout": "" + }, + { + "id": 2047510054808, + "title": "Test flow 2", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 154, + 0 + ], + "position": [ + -616.75, + 99.75 + ], + "width": 300, + "height": 207, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047510055816, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047510055960, + "type": "output", + "position": [ + 300.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "b = 2", + "stdout": "" + }, + { + "id": 2047510222024, + "title": "Test flow 3", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 191, + 0 + ], + "position": [ + -249.0, + -202.0 + ], + "width": 300, + "height": 244, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047510350296, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047510350440, + "type": "output", + "position": [ + 300.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "c = 3\r\na + b", + "stdout": "" + }, + { + "id": 2047510394344, + "title": "Test flow 4", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 165, + 0 + ], + "position": [ + -255.0, + 98.0 + ], + "width": 300, + "height": 218, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047510395352, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047510395496, + "type": "output", + "position": [ + 300.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "b = 3\r\nb", + "stdout": "" + }, + { + "id": 2047510572632, + "title": "Test flow 6", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 202, + 0 + ], + "position": [ + 522.0, + -202.0 + ], + "width": 300, + "height": 255, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047510594184, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047510594328, + "type": "output", + "position": [ + 300.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "e = 5\r\na + b + c + d", + "stdout": "" + }, + { + "id": 2047511620200, + "title": "Test flow 7", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 211, + 0 + ], + "position": [ + 504.75, + 76.75 + ], + "width": 300, + "height": 264, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047511621208, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047511621352, + "type": "output", + "position": [ + 300.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "f = 6", + "stdout": "" + }, + { + "id": 2047511818888, + "title": "Test flow 8", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 204, + 0 + ], + "position": [ + 924.75, + -199.0 + ], + "width": 364, + "height": 257, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047511819896, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047511820040, + "type": "output", + "position": [ + 364.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "g = 7\r\na + b + c + d + e + f", + "stdout": "" + }, + { + "id": 2047514048984, + "title": "Markdown", + "block_type": "OCBMarkdownBlock", + "splitter_pos": [ + 0, + 130 + ], + "position": [ + -292.5, + 432.5 + ], + "width": 347, + "height": 183, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [], + "text": "These tests check if flow execution works without edges" + }, + { + "id": 2047515370984, + "title": "Test no connection 1", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 199, + 0 + ], + "position": [ + 181.0, + 376.5 + ], + "width": 347, + "height": 252, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047515371992, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047515372136, + "type": "output", + "position": [ + 347.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "a = 1\r\na", + "stdout": "" + }, + { + "id": 2047515582680, + "title": "Test input only 1", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 250, + 0 + ], + "position": [ + -238.75, + 670.0 + ], + "width": 304, + "height": 303, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047515583688, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047515583832, + "type": "output", + "position": [ + 304.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "a = 1", + "stdout": "" + }, + { + "id": 2047516568312, + "title": "Test input only 2", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 236, + 0 + ], + "position": [ + 176.25, + 663.75 + ], + "width": 350, + "height": 289, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047516569320, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047516569464, + "type": "output", + "position": [ + 350.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "b = 2\r\na + b", + "stdout": "" + }, + { + "id": 2047517406264, + "title": "Test output only 1", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 209, + 0 + ], + "position": [ + 179.0, + 988.0 + ], + "width": 326, + "height": 262, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047517407272, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047517407416, + "type": "output", + "position": [ + 326.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "a = 1", + "stdout": "" + }, + { + "id": 2047520151448, + "title": "Test output only 2", + "block_type": "OCBCodeBlock", + "splitter_pos": [ + 202, + 0 + ], + "position": [ + 582.0, + 992.0 + ], + "width": 300, + "height": 255, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [ + { + "id": 2047520152456, + "type": "input", + "position": [ + 0.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + }, + { + "id": 2047520152600, + "type": "output", + "position": [ + 300.0, + 48.0 + ], + "metadata": { + "color": "#FF55FFF0", + "linecolor": "#FF000000", + "linewidth": 1.0, + "radius": 10.0 + } + } + ], + "source": "b = 2\r\na + b", + "stdout": "" + }, + { + "id": 2047565442936, + "title": "Markdown", + "block_type": "OCBMarkdownBlock", + "splitter_pos": [ + 0, + 131 + ], + "position": [ + -438.75, + -438.75 + ], + "width": 445, + "height": 184, + "metadata": { + "title_metadata": { + "color": "white", + "font": "Ubuntu", + "size": 10 + } + }, + "sockets": [], + "text": "**Test flow tests the general behavior of flow execution:**\r\n\r\n\tExecuting 6 left should output 4\r\n\r\n\tExecuting 6 right should output 21 in block 8\r\n" + } + ], + "edges": [ + { + "id": 2047510155912, + "path_type": "bezier", + "source": { + "block": 2047515582680, + "socket": 2047515583832 + }, + "destination": { + "block": 2047516568312, + "socket": 2047516569320 + } + }, + { + "id": 2047514047112, + "path_type": "bezier", + "source": { + "block": 2047509975832, + "socket": 2047509976984 + }, + "destination": { + "block": 2047510222024, + "socket": 2047510350296 + } + }, + { + "id": 2047515121560, + "path_type": "bezier", + "source": { + "block": 2047510054808, + "socket": 2047510055960 + }, + "destination": { + "block": 2047510222024, + "socket": 2047510350296 + } + }, + { + "id": 2047515184584, + "path_type": "bezier", + "source": { + "block": 2047510054808, + "socket": 2047510055960 + }, + "destination": { + "block": 2047510394344, + "socket": 2047510395352 + } + }, + { + "id": 2047515243864, + "path_type": "bezier", + "source": { + "block": 2047510222024, + "socket": 2047510350440 + }, + "destination": { + "block": 2047380828024, + "socket": 2047509615672 + } + }, + { + "id": 2047515295464, + "path_type": "bezier", + "source": { + "block": 2047380828024, + "socket": 2047509615816 + }, + "destination": { + "block": 2047510572632, + "socket": 2047510594184 + } + }, + { + "id": 2047515355896, + "path_type": "bezier", + "source": { + "block": 2047510572632, + "socket": 2047510594328 + }, + "destination": { + "block": 2047511818888, + "socket": 2047511819896 + } + }, + { + "id": 2047515682712, + "path_type": "bezier", + "source": { + "block": 2047511620200, + "socket": 2047511621352 + }, + "destination": { + "block": 2047511818888, + "socket": 2047511819896 + } + }, + { + "id": 2047521474312, + "path_type": "bezier", + "source": { + "block": 2047517406264, + "socket": 2047517407416 + }, + "destination": { + "block": 2047520151448, + "socket": 2047520152456 + } + } + ] +} \ No newline at end of file diff --git a/tests/integration/blocks/test_flow.py b/tests/integration/blocks/test_flow.py new file mode 100644 index 00000000..385fb00a --- /dev/null +++ b/tests/integration/blocks/test_flow.py @@ -0,0 +1,55 @@ +# OpenCodeBlock an open-source tool for modular visual programing in python +# Copyright (C) 2021 Mathïs FEDERICO + +""" +Integration tests for the OCBCodeBlocks. +""" + +import pyautogui +import pytest +from pytestqt.qtbot import QtBot + +from PyQt5.QtCore import QPointF + +from opencodeblocks.blocks.codeblock import OCBCodeBlock +from opencodeblocks.graphics.window import OCBWindow +from opencodeblocks.graphics.widget import OCBWidget + +from tests.integration.utils import apply_function_inapp, CheckingQueue + + +class TestCodeBlocks: + + @pytest.fixture(autouse=True) + def setup(self): + """ Setup reused variables. """ + self.window = OCBWindow() + self.ocb_widget = OCBWidget() + self.subwindow = self.window.mdiArea.addSubWindow(self.ocb_widget) + self.subwindow.show() + + self.ocb_widget.scene.load("tests/assets/flow_test.ipyg") + + titles = ["Test flow 5", "Test flow 4", "Test no connection 1", + "Test input only 2", "Test output only 1"] + self.blocks_to_run = [None]*5 + for item in self.ocb_widget.scene.items(): + if isinstance(item, OCBCodeBlock): + if item.title in titles: + self.blocks_to_run[titles.index(item.title)] = item + + def test_flow_left(self, qtbot: QtBot): + """ Correct flow when pressing left run """ + + def testing_run(msgQueue: CheckingQueue): + + block_to_run: OCBCodeBlock = self.blocks_to_run[0] + block_to_not_run: OCBCodeBlock = self.blocks_to_run[1] + + block_to_run.run_left() + + msgQueue.check_equal(block_to_run.stdout.strip(), "6") + msgQueue.check_equal(block_to_not_run.stdout.strip(), "") + msgQueue.stop() + + apply_function_inapp(self.window, testing_run) From 32c1752d8019cf010cdc9ebdee95a46adc17ae7e Mon Sep 17 00:00:00 2001 From: AlexandreSajus Date: Thu, 9 Dec 2021 11:41:51 +0100 Subject: [PATCH 2/5] :umbrella: adds one functional flow test --- tests/integration/blocks/test_flow.py | 8 +++++++- tests/integration/utils.py | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/integration/blocks/test_flow.py b/tests/integration/blocks/test_flow.py index 385fb00a..22a297d7 100644 --- a/tests/integration/blocks/test_flow.py +++ b/tests/integration/blocks/test_flow.py @@ -9,6 +9,8 @@ import pytest from pytestqt.qtbot import QtBot +import time + from PyQt5.QtCore import QPointF from opencodeblocks.blocks.codeblock import OCBCodeBlock @@ -46,7 +48,11 @@ def testing_run(msgQueue: CheckingQueue): block_to_run: OCBCodeBlock = self.blocks_to_run[0] block_to_not_run: OCBCodeBlock = self.blocks_to_run[1] - block_to_run.run_left() + def run_block(): + block_to_run.run_left() + + msgQueue.run_lambda(run_block) + time.sleep(0.5) msgQueue.check_equal(block_to_run.stdout.strip(), "6") msgQueue.check_equal(block_to_not_run.stdout.strip(), "") diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 956a7f7f..d5cde156 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -18,6 +18,7 @@ STOP_MSG = "stop" CHECK_MSG = "check" +RUN_MSG = "run" class CheckingQueue(Queue): @@ -25,6 +26,9 @@ class CheckingQueue(Queue): def check_equal(self, a, b, msg=""): self.put([CHECK_MSG, a, b, msg]) + def run_lambda(self, func: Callable, *args, **kwargs): + self.put([RUN_MSG, func, args, kwargs]) + def stop(self): self.put([STOP_MSG]) @@ -48,5 +52,7 @@ def apply_function_inapp(window: OCBWindow, run_func: Callable): check.equal(msg[1], msg[2], msg[3]) elif msg[0] == STOP_MSG: stop = True + elif msg[0] == RUN_MSG: + msg[1](*msg[2], **msg[3]) t.join() window.close() From 4ae596d19222cc9be8363a7e2f916d4e9d7ef6d1 Mon Sep 17 00:00:00 2001 From: AlexandreSajus Date: Sun, 12 Dec 2021 17:18:36 +0100 Subject: [PATCH 3/5] :umbrella: tests execution flow --- examples/flow.ipyg | 2 +- tests/assets/flow_test.ipyg | 2 +- tests/integration/blocks/test_flow.py | 103 ++++++++++++++++++++++---- 3 files changed, 90 insertions(+), 17 deletions(-) diff --git a/examples/flow.ipyg b/examples/flow.ipyg index 9fce6f7a..7f839f60 100644 --- a/examples/flow.ipyg +++ b/examples/flow.ipyg @@ -749,7 +749,7 @@ } }, "sockets": [], - "text": "**Test flow tests the general behavior of flow execution:**\r\n\r\n\tExecuting 6 left should output 4\r\n\r\n\tExecuting 6 right should output 21 in block 8\r\n" + "text": "**Test flow tests the general behavior of flow execution:**\r\n\r\n\tExecuting 6 left should output 6\r\n\r\n\tExecuting 6 right should output 21 in block 8\r\n" } ], "edges": [ diff --git a/tests/assets/flow_test.ipyg b/tests/assets/flow_test.ipyg index 0a20333b..414cfd1c 100644 --- a/tests/assets/flow_test.ipyg +++ b/tests/assets/flow_test.ipyg @@ -749,7 +749,7 @@ } }, "sockets": [], - "text": "**Test flow tests the general behavior of flow execution:**\r\n\r\n\tExecuting 6 left should output 4\r\n\r\n\tExecuting 6 right should output 21 in block 8\r\n" + "text": "**Test flow tests the general behavior of flow execution:**\r\n\r\n\tExecuting 6 left should output 6\r\n\r\n\tExecuting 6 right should output 21 in block 8\r\n" } ], "edges": [ diff --git a/tests/integration/blocks/test_flow.py b/tests/integration/blocks/test_flow.py index 22a297d7..8409e660 100644 --- a/tests/integration/blocks/test_flow.py +++ b/tests/integration/blocks/test_flow.py @@ -5,14 +5,9 @@ Integration tests for the OCBCodeBlocks. """ -import pyautogui import pytest -from pytestqt.qtbot import QtBot - import time -from PyQt5.QtCore import QPointF - from opencodeblocks.blocks.codeblock import OCBCodeBlock from opencodeblocks.graphics.window import OCBWindow from opencodeblocks.graphics.widget import OCBWidget @@ -21,10 +16,11 @@ class TestCodeBlocks: + """Test the execution flow""" @pytest.fixture(autouse=True) def setup(self): - """ Setup reused variables. """ + """Setup reused variables.""" self.window = OCBWindow() self.ocb_widget = OCBWidget() self.subwindow = self.window.mdiArea.addSubWindow(self.ocb_widget) @@ -32,25 +28,35 @@ def setup(self): self.ocb_widget.scene.load("tests/assets/flow_test.ipyg") - titles = ["Test flow 5", "Test flow 4", "Test no connection 1", - "Test input only 2", "Test output only 1"] - self.blocks_to_run = [None]*5 + self.titles = [ + "Test flow 5", + "Test flow 4", + "Test flow 8", + "Test no connection 1", + ] + self.blocks_to_run = [None] * len(self.titles) for item in self.ocb_widget.scene.items(): if isinstance(item, OCBCodeBlock): - if item.title in titles: - self.blocks_to_run[titles.index(item.title)] = item + if item.title in self.titles: + self.blocks_to_run[self.titles.index(item.title)] = item - def test_flow_left(self, qtbot: QtBot): - """ Correct flow when pressing left run """ + def test_flow_left(self): + """Correct flow when pressing left run""" def testing_run(msgQueue: CheckingQueue): - block_to_run: OCBCodeBlock = self.blocks_to_run[0] - block_to_not_run: OCBCodeBlock = self.blocks_to_run[1] + block_to_run: OCBCodeBlock = self.blocks_to_run[ + self.titles.index("Test flow 5") + ] + block_to_not_run: OCBCodeBlock = self.blocks_to_run[ + self.titles.index("Test flow 4") + ] def run_block(): block_to_run.run_left() + # Run the execution in a separate thread + # to give time for the outputs to show before checking them msgQueue.run_lambda(run_block) time.sleep(0.5) @@ -59,3 +65,70 @@ def run_block(): msgQueue.stop() apply_function_inapp(self.window, testing_run) + + def test_flow_right(self): + """Correct flow when pressing right run""" + + def testing_run(msgQueue: CheckingQueue): + + block_to_run: OCBCodeBlock = self.blocks_to_run[ + self.titles.index("Test flow 5") + ] + block_output: OCBCodeBlock = self.blocks_to_run[ + self.titles.index("Test flow 8") + ] + block_to_not_run: OCBCodeBlock = self.blocks_to_run[ + self.titles.index("Test flow 4") + ] + + def run_block(): + block_to_run.run_right() + + msgQueue.run_lambda(run_block) + time.sleep(0.5) + + msgQueue.check_equal(block_output.stdout.strip(), "21") + msgQueue.check_equal(block_to_not_run.stdout.strip(), "") + msgQueue.stop() + + apply_function_inapp(self.window, testing_run) + + def test_no_connection_left(self): + """Run_left when no connection""" + + def testing_run(msgQueue: CheckingQueue): + + block_to_run: OCBCodeBlock = self.blocks_to_run[ + self.titles.index("Test no connection 1") + ] + + def run_block(): + block_to_run.run_left() + + msgQueue.run_lambda(run_block) + time.sleep(0.5) + + msgQueue.check_equal(block_to_run.stdout.strip(), "1") + msgQueue.stop() + + apply_function_inapp(self.window, testing_run) + + def test_no_connection_right(self): + """Run_right when no connection""" + + def testing_run(msgQueue: CheckingQueue): + + block_to_run: OCBCodeBlock = self.blocks_to_run[ + self.titles.index("Test no connection 1") + ] + + def run_block(): + block_to_run.run_right() + + msgQueue.run_lambda(run_block) + time.sleep(0.5) + + # Just check that it doesn't crash + msgQueue.stop() + + apply_function_inapp(self.window, testing_run) From 346c6e92ceabce847507a92c8aea74ce243b8f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=AFs=20F=C3=A9d=C3=A9rico?= Date: Mon, 13 Dec 2021 17:32:00 +0100 Subject: [PATCH 4/5] :memo: Update test_flow docstrings --- tests/integration/blocks/test_flow.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/integration/blocks/test_flow.py b/tests/integration/blocks/test_flow.py index 8409e660..3e298b2d 100644 --- a/tests/integration/blocks/test_flow.py +++ b/tests/integration/blocks/test_flow.py @@ -2,7 +2,7 @@ # Copyright (C) 2021 Mathïs FEDERICO """ -Integration tests for the OCBCodeBlocks. +Integration tests for the execution flow. """ import pytest @@ -15,8 +15,8 @@ from tests.integration.utils import apply_function_inapp, CheckingQueue -class TestCodeBlocks: - """Test the execution flow""" +class TestExecutionFlow: + """Execution flow""" @pytest.fixture(autouse=True) def setup(self): @@ -41,7 +41,7 @@ def setup(self): self.blocks_to_run[self.titles.index(item.title)] = item def test_flow_left(self): - """Correct flow when pressing left run""" + """run block and previous blocks when pressing left run.""" def testing_run(msgQueue: CheckingQueue): @@ -67,7 +67,7 @@ def run_block(): apply_function_inapp(self.window, testing_run) def test_flow_right(self): - """Correct flow when pressing right run""" + """run block and next blocks when pressing right run.""" def testing_run(msgQueue: CheckingQueue): @@ -94,7 +94,7 @@ def run_block(): apply_function_inapp(self.window, testing_run) def test_no_connection_left(self): - """Run_left when no connection""" + """run block only when no previous connection.""" def testing_run(msgQueue: CheckingQueue): @@ -114,7 +114,7 @@ def run_block(): apply_function_inapp(self.window, testing_run) def test_no_connection_right(self): - """Run_right when no connection""" + """run block only when no next connection.""" def testing_run(msgQueue: CheckingQueue): From 9ac9e99c15a4da4c053331697f272cb05d50ea04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=AFs=20F=C3=A9d=C3=A9rico?= Date: Mon, 13 Dec 2021 17:59:25 +0100 Subject: [PATCH 5/5] :fire: Remove flow.ipyg from examples --- examples/flow.ipyg | 865 --------------------------------------------- 1 file changed, 865 deletions(-) delete mode 100644 examples/flow.ipyg diff --git a/examples/flow.ipyg b/examples/flow.ipyg deleted file mode 100644 index 7f839f60..00000000 --- a/examples/flow.ipyg +++ /dev/null @@ -1,865 +0,0 @@ -{ - "id": 2047380826296, - "blocks": [ - { - "id": 2047380828024, - "title": "Test flow 5", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 203, - 0 - ], - "position": [ - 126.0, - -202.0 - ], - "width": 316, - "height": 256, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047509615672, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047509615816, - "type": "output", - "position": [ - 316.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "d = 4\r\na + b + c", - "stdout": "" - }, - { - "id": 2047509975832, - "title": "Test flow 1", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 187, - 0 - ], - "position": [ - -616.0, - -200.0 - ], - "width": 302, - "height": 240, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047509976840, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047509976984, - "type": "output", - "position": [ - 302.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "a = 1", - "stdout": "" - }, - { - "id": 2047510054808, - "title": "Test flow 2", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 154, - 0 - ], - "position": [ - -616.75, - 99.75 - ], - "width": 300, - "height": 207, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047510055816, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047510055960, - "type": "output", - "position": [ - 300.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "b = 2", - "stdout": "" - }, - { - "id": 2047510222024, - "title": "Test flow 3", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 191, - 0 - ], - "position": [ - -249.0, - -202.0 - ], - "width": 300, - "height": 244, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047510350296, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047510350440, - "type": "output", - "position": [ - 300.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "c = 3\r\na + b", - "stdout": "" - }, - { - "id": 2047510394344, - "title": "Test flow 4", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 165, - 0 - ], - "position": [ - -255.0, - 98.0 - ], - "width": 300, - "height": 218, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047510395352, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047510395496, - "type": "output", - "position": [ - 300.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "b = 3", - "stdout": "" - }, - { - "id": 2047510572632, - "title": "Test flow 6", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 202, - 0 - ], - "position": [ - 522.0, - -202.0 - ], - "width": 300, - "height": 255, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047510594184, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047510594328, - "type": "output", - "position": [ - 300.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "e = 5\r\na + b + c + d", - "stdout": "" - }, - { - "id": 2047511620200, - "title": "Test flow 7", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 211, - 0 - ], - "position": [ - 504.75, - 76.75 - ], - "width": 300, - "height": 264, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047511621208, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047511621352, - "type": "output", - "position": [ - 300.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "f = 6", - "stdout": "" - }, - { - "id": 2047511818888, - "title": "Test flow 8", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 204, - 0 - ], - "position": [ - 924.75, - -199.0 - ], - "width": 364, - "height": 257, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047511819896, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047511820040, - "type": "output", - "position": [ - 364.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "g = 7\r\na + b + c + d + e + f", - "stdout": "" - }, - { - "id": 2047514048984, - "title": "Markdown", - "block_type": "OCBMarkdownBlock", - "splitter_pos": [ - 0, - 130 - ], - "position": [ - -292.5, - 432.5 - ], - "width": 347, - "height": 183, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [], - "text": "These tests check if flow execution works without edges" - }, - { - "id": 2047515370984, - "title": "Test no connection 1", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 199, - 0 - ], - "position": [ - 181.0, - 376.5 - ], - "width": 347, - "height": 252, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047515371992, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047515372136, - "type": "output", - "position": [ - 347.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "a = 1\r\na", - "stdout": "" - }, - { - "id": 2047515582680, - "title": "Test input only 1", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 250, - 0 - ], - "position": [ - -238.75, - 670.0 - ], - "width": 304, - "height": 303, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047515583688, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047515583832, - "type": "output", - "position": [ - 304.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "a = 1", - "stdout": "" - }, - { - "id": 2047516568312, - "title": "Test input only 2", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 236, - 0 - ], - "position": [ - 176.25, - 663.75 - ], - "width": 350, - "height": 289, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047516569320, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047516569464, - "type": "output", - "position": [ - 350.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "b = 2\r\na + b", - "stdout": "" - }, - { - "id": 2047517406264, - "title": "Test output only 1", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 209, - 0 - ], - "position": [ - 179.0, - 988.0 - ], - "width": 326, - "height": 262, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047517407272, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047517407416, - "type": "output", - "position": [ - 326.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "a = 1", - "stdout": "" - }, - { - "id": 2047520151448, - "title": "Test output only 2", - "block_type": "OCBCodeBlock", - "splitter_pos": [ - 202, - 0 - ], - "position": [ - 582.0, - 992.0 - ], - "width": 300, - "height": 255, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [ - { - "id": 2047520152456, - "type": "input", - "position": [ - 0.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - }, - { - "id": 2047520152600, - "type": "output", - "position": [ - 300.0, - 48.0 - ], - "metadata": { - "color": "#FF55FFF0", - "linecolor": "#FF000000", - "linewidth": 1.0, - "radius": 10.0 - } - } - ], - "source": "b = 2\r\na + b", - "stdout": "" - }, - { - "id": 2047565442936, - "title": "Markdown", - "block_type": "OCBMarkdownBlock", - "splitter_pos": [ - 0, - 131 - ], - "position": [ - -438.75, - -438.75 - ], - "width": 445, - "height": 184, - "metadata": { - "title_metadata": { - "color": "white", - "font": "Ubuntu", - "size": 10 - } - }, - "sockets": [], - "text": "**Test flow tests the general behavior of flow execution:**\r\n\r\n\tExecuting 6 left should output 6\r\n\r\n\tExecuting 6 right should output 21 in block 8\r\n" - } - ], - "edges": [ - { - "id": 2047510155912, - "path_type": "bezier", - "source": { - "block": 2047515582680, - "socket": 2047515583832 - }, - "destination": { - "block": 2047516568312, - "socket": 2047516569320 - } - }, - { - "id": 2047514047112, - "path_type": "bezier", - "source": { - "block": 2047509975832, - "socket": 2047509976984 - }, - "destination": { - "block": 2047510222024, - "socket": 2047510350296 - } - }, - { - "id": 2047515121560, - "path_type": "bezier", - "source": { - "block": 2047510054808, - "socket": 2047510055960 - }, - "destination": { - "block": 2047510222024, - "socket": 2047510350296 - } - }, - { - "id": 2047515184584, - "path_type": "bezier", - "source": { - "block": 2047510054808, - "socket": 2047510055960 - }, - "destination": { - "block": 2047510394344, - "socket": 2047510395352 - } - }, - { - "id": 2047515243864, - "path_type": "bezier", - "source": { - "block": 2047510222024, - "socket": 2047510350440 - }, - "destination": { - "block": 2047380828024, - "socket": 2047509615672 - } - }, - { - "id": 2047515295464, - "path_type": "bezier", - "source": { - "block": 2047380828024, - "socket": 2047509615816 - }, - "destination": { - "block": 2047510572632, - "socket": 2047510594184 - } - }, - { - "id": 2047515355896, - "path_type": "bezier", - "source": { - "block": 2047510572632, - "socket": 2047510594328 - }, - "destination": { - "block": 2047511818888, - "socket": 2047511819896 - } - }, - { - "id": 2047515682712, - "path_type": "bezier", - "source": { - "block": 2047511620200, - "socket": 2047511621352 - }, - "destination": { - "block": 2047511818888, - "socket": 2047511819896 - } - }, - { - "id": 2047521474312, - "path_type": "bezier", - "source": { - "block": 2047517406264, - "socket": 2047517407416 - }, - "destination": { - "block": 2047520151448, - "socket": 2047520152456 - } - } - ] -} \ No newline at end of file