From d82af14190e2f69cca5be02436dd838adb89147c Mon Sep 17 00:00:00 2001 From: Agsha Athalla Nurkareem <agshaathalla@gmail.com> Date: Wed, 19 Apr 2023 17:37:58 +0700 Subject: [PATCH] add: test dashboard --- src/test_dashboard.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/test_dashboard.py diff --git a/src/test_dashboard.py b/src/test_dashboard.py new file mode 100644 index 0000000..7608aef --- /dev/null +++ b/src/test_dashboard.py @@ -0,0 +1,43 @@ +import pytest +import sys + +from PyQt6.QtCore import Qt, pyqtSignal, QSize +from PyQt6.QtGui import QCursor, QFont, QPixmap, QMovie, QIcon +from PyQt6.QtWidgets import QApplication, QLabel, QPushButton, QWidget, QScrollArea, QVBoxLayout, QHBoxLayout +import sqlite3 +import random + +from dashboard import dashboard + +cur = sqlite3.connect('fitu.db') +con = cur.cursor() + +@pytest.fixture +def app(): + app = dashboard() + yield app + +def test_dashboard(app, qtbot): + assert app.windowTitle() == 'FitU - Dashboard' + assert app.height() == 720 + assert app.width() == 1280 + +def test_element(app, qtbot): + latihan = cur.execute(""" + SELECT * FROM riwayat_latihan """).fetchall() + + if (len(latihan)<=0): + assert len(app.findChildren(QPushButton)) == 5 + assert len(app.findChildren(QLabel)) == 8 + else: + assert len(app.findChildren(QPushButton)) == 7 + assert len(app.findChildren(QLabel)) == 21 + assert app.findChildren(QPushButton)[0].text() == 'Home' + assert app.findChildren(QPushButton)[1].text() == 'Customize' + assert app.findChildren(QPushButton)[2].text() == 'Plan' + assert app.findChildren(QPushButton)[3].text() == 'List' + assert app.findChildren(QPushButton)[4].text() == "Let's Start!" + + + + -- GitLab