Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests #31

Merged
merged 23 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
39d5ba0
:umbrella: Add integration tests.
vanyle Nov 14, 2021
111b251
:umbrella: Changed the CI to ubuntu in an attempt to be able to use t…
vanyle Nov 14, 2021
9cf2b68
:umbrella: Added DISPLAY to the environment variables
vanyle Nov 14, 2021
57d41f6
:umbrella: Change location where integration tests are performed
vanyle Nov 14, 2021
5c46430
:umbrella: Attempt to make x11 work on CI
vanyle Nov 14, 2021
d1aac7d
:umbrella: Update dependencies for CI and make the test linux friendly.
vanyle Nov 14, 2021
5fba40c
:umbrella: Attempt to fix CI errors
vanyle Nov 14, 2021
3b567c6
:umbrella: Next attempt
vanyle Nov 14, 2021
fbdc5a1
:umbrella: Made stuff root
vanyle Nov 14, 2021
4244304
:umbrella: Use `sudo` instead of `su`, because the commands are not r…
vanyle Nov 15, 2021
d7f330a
:beetle: Add sudo at the correct places
vanyle Nov 15, 2021
225b986
:umbrella: Attempt to fix CI. Fixed a bug in the tests where the posi…
vanyle Nov 15, 2021
74e969e
:umbrella: Proper integration with qtbot. qtbot manages the app part.
vanyle Nov 15, 2021
17eb81c
:umbrella: Added -s option to pytest to display prints inside tests
vanyle Nov 15, 2021
90f32b3
:umbrella: rewrite the CI
vanyle Nov 15, 2021
6794f26
:umbrella: Created file with touch to resolve FileNotFound
vanyle Nov 15, 2021
190c706
:umbrella: Add integration test for opening files
vanyle Nov 15, 2021
35ca8e6
:umbrella: Made CI output less noisy
vanyle Nov 15, 2021
6dd3ed6
:umbrella: Fix an issue where the test would crash on windows
vanyle Nov 15, 2021
d756df4
:umbrella: Add integration test support for the `tests` CI. Comment k…
vanyle Nov 16, 2021
64373ee
:umbrella: A linter has no place in a testing CI. This is the job of …
vanyle Nov 16, 2021
44c1121
:umbrella: Set the DISPLAY of the test to xvfb
vanyle Nov 16, 2021
52dd36a
:umbrella: Add end-of-line at the end of the file
vanyle Nov 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
☔ Proper integration with qtbot. qtbot manages the app part.
  • Loading branch information
vanyle committed Nov 15, 2021
commit 74e969eee56b102a91b20666ce53e36f5941d375
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
filterwarnings =
ignore::DeprecationWarning
addopts = --pspec
qt_api=pyqt5
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pytest-cov
pytest-mock
pytest-check
pytest-pspec
pytest-qt
pyautogui
pylint
pylint-pytest
36 changes: 12 additions & 24 deletions tests/integration/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,34 @@
import pyautogui

# The window and app variable used by every test.
# The same app is used for every test.
wnd = None
app = None


@pytest.fixture
def clean_up():
global wnd,app
global wnd

if wnd != None:
wnd.close()
wnd = None
if app != None:
app.quit()
app = None

@pytest.mark.usefixtures('clean_up')
def test_window_opening():
def test_window_opening(qtbot):
""" The OCBWindow should open and close correctly """
global wnd,app
global wnd

from qtpy.QtWidgets import QApplication
from opencodeblocks.graphics.blocks.codeblock import OCBCodeBlock, OCBBlock
from opencodeblocks.graphics.socket import OCBSocket
from opencodeblocks.graphics.window import OCBWindow

app = QApplication([])
app.setStyle('Fusion')
wnd = OCBWindow()

@pytest.mark.usefixtures('clean_up')
def test_running_python():
def test_running_python(qtbot):
""" The blocks should run arbitrary python when unfocused """
global app,wnd
global wnd

app = QApplication([])
app.setStyle('Fusion')
wnd = OCBWindow()

EXPRESSION = "3 + 5 * 2"
Expand Down Expand Up @@ -117,26 +109,25 @@ def test_running_python():
check.equal(expected_result,result)

@pytest.mark.usefixtures('clean_up')
def test_move_blocks():
def test_move_blocks(qtbot):
"""
Newly created blocks are displayed in the center.
They can be dragged around with the mouse.
"""
global app,wnd

app = QApplication([])
app.setStyle('Fusion')
global wnd
wnd = OCBWindow()

ocb_widget = OCBWidget()
wnd.mdiArea.addSubWindow(ocb_widget)
subwnd = wnd.mdiArea.addSubWindow(ocb_widget)

test_block1 = OCBCodeBlock(title="Testing block 1", source="print(1)")
ocb_widget.scene.addItem(test_block1)

test_block2 = OCBCodeBlock(title="Testing block 2", source="print(2)")
ocb_widget.scene.addItem(test_block2)

subwnd.show()

QApplication.processEvents()

expected_move_amount = [70,-30]
Expand All @@ -154,7 +145,6 @@ def testing_drag(msgQueue):
pos_block_1.setX(pos_block_1.x() + test_block1.title_height//2)
pos_block_1.setY(pos_block_1.y() + test_block1.title_height//2)

sr = ocb_widget.view.sceneRect()
pos_block_1 = ocb_widget.view.mapFromScene(pos_block_1)
pos_block_1 = ocb_widget.view.mapToGlobal(pos_block_1)

Expand Down Expand Up @@ -190,8 +180,6 @@ def testing_drag(msgQueue):
t = threading.Thread(target=testing_drag, args=(msgQueue,))
t.start()

ocb_widget.view.repaint()

while True:
QApplication.processEvents()
time.sleep(0.02)
Expand All @@ -204,4 +192,4 @@ def testing_drag(msgQueue):
t.join()

if __name__ == "__main__":
test_running_python()
test_running_python(None)