Skip to content

Commit

Permalink
☔ Add test to prevent #94 regressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
vanyle committed Dec 12, 2021
1 parent e222912 commit 657e785
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tests/integration/blocks/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
Integration tests for the OCBCodeBlocks.
"""

import pyautogui
import pytest

import time

from opencodeblocks.blocks.codeblock import OCBCodeBlock
Expand Down Expand Up @@ -37,8 +35,34 @@ def setup(self):
if item.title in titles:
self.blocks_to_run[titles.index(item.title)] = item

def test_duplicated_run(self):
""" Don't run a block twice when the execution flows """
for b in self.blocks_to_run:
b.stdout = ""

def testing_no_duplicates(msgQueue: CheckingQueue):

block_to_run: OCBCodeBlock = self.blocks_to_run[0]

def run_block():
block_to_run.run_right()

msgQueue.run_lambda(run_block)
time.sleep(0.1)
while block_to_run.is_running:
time.sleep(0.1) # wait for the execution to finish.

# 6 and not 6\n6
msgQueue.check_equal(block_to_run.stdout.strip(), "6")
msgQueue.stop()

apply_function_inapp(self.window, testing_no_duplicates)

def test_flow_left(self):
""" Correct flow when pressing left run """

for b in self.blocks_to_run:
b.stdout = ""

def testing_run(msgQueue: CheckingQueue):

Expand All @@ -58,6 +82,6 @@ def run_block():
msgQueue.stop()

apply_function_inapp(self.window, testing_run)

def test_finish(self):
self.window.close()

0 comments on commit 657e785

Please sign in to comment.