Skip to content
Snippets Groups Projects
Commit 144259dc authored by Petter Sagvold's avatar Petter Sagvold
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://gitlab.stud.idi.ntnu.no/bachelor-paa-bittet/soitool into MainWindow
parents 3de2829f 184eaba3
No related branches found
No related tags found
1 merge request!1Oppsett av skjelettet til hovedvinduet
Pipeline #70571 passed
......@@ -8,28 +8,28 @@ job_lint_flake8:
image: morkolai/soitool-ci
script:
- flake8 --version
- flake8 soitool
- flake8 --config scripts/.flake8 soitool test
job_lint_pylint:
stage: lint
image: morkolai/soitool-ci
script:
- pylint --version
- pylint --rcfile=scripts/.pylintrc soitool
- pylint --rcfile=scripts/.pylintrc soitool test
job_lint_bandit:
stage: lint
image: morkolai/soitool-ci
script:
- bandit --version
- bandit -r soitool
- bandit -r soitool test
job_lint_pydocstyle:
stage: lint
image: morkolai/soitool-ci
script:
- pydocstyle --version
- pydocstyle --convention=numpy soitool
- pydocstyle --match '.*.py' --convention=numpy soitool test
job_test_gui_ubuntu_vnc:
stage: test
......@@ -37,7 +37,7 @@ job_test_gui_ubuntu_vnc:
script:
# -platform because running with a screen is not supported
# https://stackoverflow.com/questions/17106315/failed-to-load-platform-plugin-xcb-while-launching-qt5-app-on-linux-without
- QT_QPA_PLATFORM=vnc python3 -m unittest test.test_main
- QT_QPA_PLATFORM=vnc python3.7 -m unittest test.test_main
job_test_gui_windows:
stage: test
......
FROM ubuntu:16.04
FROM ubuntu:18.04
# This Dockerfile describes the container used in .gitlab-ci.yml
......@@ -24,4 +24,20 @@ RUN apt-get install -y libegl1-mesa-dev \
WORKDIR /code
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
RUN python3.7 -m pip install setuptools
RUN python3.7 -m pip install -r requirements.txt
# Set the locale
# Necessary for container to properly handle æøå
# See issue #10
RUN apt-get install -y locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# From https://it.i88.ca/2016/03/how-to-fix-importerror-libgssapikrb5so2.html
# python3.7 -m unittest fails without this
RUN apt-get -y install libgssapi-krb5-2
[flake8]
; ignorerer sjekk for lange linjer, ettersom dette gjøres i pylint
; vi vil tillate lange linjer som avsluttes med link, og dette er mulig i
; pylint, men såvidt vi vet ikke mulig i flake8
ignore = E501
......@@ -275,7 +275,7 @@ redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
expected-line-ending-format=
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
ignore-long-lines=^.*<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
......
if ($args.Count -eq 0){
$files=Get-ChildItem -recurse| Where-Object {$_.name -match "[A-Za-z0-9_]+\.py" -And $_.Name -notmatch "pyc"} | % { $_.FullName }
$files=Get-ChildItem -recurse |
Where-Object {$_.name -match "[A-Za-z0-9_]+\.py" -And $_.Name -notmatch "pyc"} |
% { $_.FullName }
Write-Output "`nChecking all .py-files"
}
else{
......@@ -9,11 +11,11 @@ else{
}
for ($i=0; $i -lt $files.Length; $i++){
Write-Output "`n==============================$(Split-Path $files[$i] -leaf)=============================="
Write-Output "`n============================$(Split-Path $files[$i] -leaf)============================"
Write-Output "===PYLINT===`n"
pylint --rcfile=./scripts/.pylintrc $files[$i]
Write-Output "`n===FLAKE8===`n"
flake8 $files[$i]
flake8 --config ./scripts/.flake8 $files[$i]
Write-Output "`n===BANDIT===`n"
bandit $files[$i]
Write-Output "`n===PYDOCSTYLE===`n"
......
......@@ -6,14 +6,14 @@ else
files=$@
fi
for filnavn in $files; do
printf "==============================$filnavn==============================\n"
for fileName in $files; do
printf "============================$fileName============================\n"
printf "\n===PYLINT===\n"
pylint --rcfile=./scripts/.pylintrc $filnavn
pylint --rcfile=./scripts/.pylintrc $fileName
printf "===FLAKE8===\n"
flake8 $filnavn
flake8 --config ./scripts/.flake8 $fileName
printf "\n===BANDIT===\n"
bandit $filnavn
bandit $fileName
printf "\n===PYDOCSTYLE===\n"
pydocstyle --convention=numpy $filnavn
pydocstyle --convention=numpy $fileName
done
"""Tester koden vår."""
"""Test CoolWidget."""
import unittest
import sys
from datetime import datetime as datetime_, timedelta
from PySide2 import QtWidgets, QtTest, QtCore
from soitool import main
from PySide2 import QtGui, QtWidgets, QtTest, QtCore
# references:
# * findChild: https://srinikom.github.io/pyside-docs/PySide/QtCore/QObject.html#PySide.QtCore.PySide.QtCore.QObject.findChild
......@@ -18,48 +21,68 @@ from PySide2 import QtGui, QtWidgets, QtTest, QtCore
# moved here from setUp to avoid annoying startup messages
app = QtWidgets.QApplication(sys.argv)
def wait(msec):
QtTest.QTest.qWait(msec)
"""Venter msec millisekunder.
Bruker https://stackoverflow.com/a/34745326/3545896
Parameter
-----
msec : number
msec to wait
"""
end = datetime_.now() + timedelta(milliseconds=msec)
while datetime_.now() < end:
app.processEvents()
class TestMain(unittest.TestCase):
"""TestCase for main."""
def setUp(self):
"""Forbereder widget for testing."""
self.test_text1 = "A bad boy"
self.test_text2 = "Hei Anders!"
self.widget = main.CoolWidget(self.test_text1)
self.widget.show()
def test_starts_up(self):
"""Test at widget kan starte opp."""
self.assertEqual(
self.widget.qlabel.text(),
self.test_text1,
self.widget.qlabel.text(),
self.test_text1,
)
self.assertTrue(self.widget.isVisible())
def test_change_text_ok(self):
"""Test at endring av tekst funker."""
def change_text_and_ok():
active_widget = app.activeModalWidget()
child_line_edit = active_widget.findChild(QtWidgets.QLineEdit)
while self.widget.dlg_input is None:
app.processEvents()
child_line_edit = self.widget.dlg_input.findChild(QtWidgets.QLineEdit)
QtTest.QTest.keyClicks(child_line_edit, self.test_text2)
QtTest.QTest.keyClick(child_line_edit, QtCore.Qt.Key_Enter)
QtCore.QTimer.singleShot(0, change_text_and_ok)
QtCore.QTimer.singleShot(100, change_text_and_ok)
QtTest.QTest.mouseClick(self.widget.button, QtCore.Qt.LeftButton)
self.assertEqual(
self.widget.qlabel.text(),
self.test_text2,
)
def test_change_text_not_ok(self):
"""Test at avbrytelse av endring av tekster ikke endrer tekst."""
def accept_popup():
QtTest.QTest.keyClick(app.activeModalWidget(), QtCore.Qt.Key_Enter)
def change_text_and_not_ok():
# in PySide2 we need to store a reference to this. If we don't the widget is garbage collected somehow before we get to use child_line_edit (a child of the active widget)
# in PySide2 we need to store a reference to this. If we don't the
# widget is garbage collected somehow before we get to use
# child_line_edit (a child of the active widget)
active_widget = app.activeModalWidget()
child_line_edit = active_widget.findChild(QtWidgets.QLineEdit)
......@@ -70,11 +93,12 @@ class TestMain(unittest.TestCase):
QtCore.QTimer.singleShot(0, change_text_and_not_ok)
QtTest.QTest.mouseClick(self.widget.button, QtCore.Qt.LeftButton)
self.assertNotEqual(
self.widget.qlabel.text(),
self.test_text2,
)
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment