Skip to content

Commit

Permalink
Fix failing tests and remove duplicate ones
Browse files Browse the repository at this point in the history
  • Loading branch information
Gatsik committed May 14, 2024
1 parent 75b937a commit 5776ce4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 144 deletions.
2 changes: 0 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#! /usr/bin/env python3

import sys

import pytest
Expand Down
2 changes: 1 addition & 1 deletion src/fa/game_updater/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def add_watch(self, watch: QObject) -> None:
@pyqtSlot()
def watch_finished(self) -> None:
for watch in self.watches:
if not watch.is_finished():
if not watch.isFinished():
return
# equivalent to self.accept(), but clearer
self.done(QDialog.DialogCode.Accepted)
Expand Down
118 changes: 0 additions & 118 deletions tests/fa/test_featured.py

This file was deleted.

39 changes: 16 additions & 23 deletions tests/fa/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PyQt6 import QtCore
from PyQt6 import QtWidgets

from fa import updater
from fa.game_updater.updater import UpdaterProgressDialog


class NoIsFinished(QtCore.QObject):
Expand All @@ -19,73 +19,66 @@ def run(self):


def test_updater_is_a_dialog(application):
assert isinstance(updater.UpdaterProgressDialog(None), QtWidgets.QDialog)
assert isinstance(UpdaterProgressDialog(None), QtWidgets.QDialog)


def test_updater_has_progress_bar_game_progress(application):
assert isinstance(
updater.UpdaterProgressDialog(None).gameProgress,
QtWidgets.QProgressBar,
)


def test_updater_has_progress_bar_map_progress(application):
assert isinstance(
updater.UpdaterProgressDialog(None).mapProgress,
UpdaterProgressDialog(None).gameProgress,
QtWidgets.QProgressBar,
)


def test_updater_has_progress_bar_mod_progress(application):
assert isinstance(
updater.UpdaterProgressDialog(None).mapProgress,
UpdaterProgressDialog(None).modProgress,
QtWidgets.QProgressBar,
)


def test_updater_has_method_append_log(application):
assert isinstance(
updater.UpdaterProgressDialog(None).appendLog,
UpdaterProgressDialog(None).append_log,
Callable,
)


def test_updater_append_log_accepts_string(application):
updater.UpdaterProgressDialog(None).appendLog("Hello Test")
UpdaterProgressDialog(None).append_log("Hello Test")


def test_updater_has_method_add_watch(application):
assert isinstance(
updater.UpdaterProgressDialog(None).addWatch,
UpdaterProgressDialog(None).add_watch,
Callable,
)


def test_updater_append_log_accepts_qobject_with_signals_finished(application):
updater.UpdaterProgressDialog(None).addWatch(QtCore.QThread())
UpdaterProgressDialog(None).add_watch(QtCore.QThread())


def test_updater_add_watch_raises_error_on_watch_without_signal_finished(
application,
):
with pytest.raises(AttributeError):
updater.UpdaterProgressDialog(None).addWatch(QtCore.QObject())
UpdaterProgressDialog(None).add_watch(QtCore.QObject())


def test_updater_watch_finished_raises_error_on_watch_without_method_finished(
application,
):
u = updater.UpdaterProgressDialog(None)
u.addWatch(NoIsFinished())
u = UpdaterProgressDialog(None)
u.add_watch(NoIsFinished())
with pytest.raises(AttributeError):
u.watchFinished()


def test_updater_hides_and_accepts_if_all_watches_are_finished(application):
u = updater.UpdaterProgressDialog(None)
u = UpdaterProgressDialog(None)
t = NoOpThread()

u.addWatch(t)
u.add_watch(t)
u.show()
t.start()

Expand All @@ -100,12 +93,12 @@ def test_updater_hides_and_accepts_if_all_watches_are_finished(application):
def test_updater_does_not_hide_and_accept_before_all_watches_are_finished(
application,
):
u = updater.UpdaterProgressDialog(None)
u = UpdaterProgressDialog(None)
t = NoOpThread()
t_not_finished = QtCore.QThread()

u.addWatch(t)
u.addWatch(t_not_finished)
u.add_watch(t)
u.add_watch(t_not_finished)
u.show()
t.start()

Expand Down

0 comments on commit 5776ce4

Please sign in to comment.