-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.py
63 lines (49 loc) · 1.62 KB
/
objects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from PyQt6.QtCore import pyqtSignal
from PyQt6.QtWidgets import QWidget
from abc import ABC, abstractmethod
from enum import Enum
# A widget representing one step of a test
class TestWidget(QWidget):
# Emitted when the widget is displayed
# Use to set focus
displayed = pyqtSignal()
# The test widget is presumed read-only after emitting finished or crashed
# It will remain rendered until advance is passed
finished = pyqtSignal(object)
crashed = pyqtSignal(object)
advance = pyqtSignal(object)
# Base class for a test step
class TestStep(ABC):
@abstractmethod
def __init__(self, name: str, data_field: str = None) -> None:
self._name = name
self._data_field = data_field
def get_name(self) -> str:
return self._name
# The field the data output should be placed under
def get_data_field(self) -> str:
return self._data_field
# Given data returned by the widget, returns an array with
# length get_output_count() whose values are colors
def get_output_action(self, in_data, out_data) -> list[str]:
return True
# Data is specific to this run
# config is global and final
@abstractmethod
def create_widget(self, data: object) -> TestWidget:
pass
class TestStage(Enum):
SETUP = 0
RUNTIME = 1
SHUTDOWN = 2
class TestFinishedBehavior(Enum):
SKIP_TO_CLEANUP = 0,
NEXT_STEP = 1
# A test flow
class TestFlow(ABC):
@abstractmethod
def get_steps(self, flow: TestStage) -> list[TestStep]:
pass
@abstractmethod
def get_watcher(self, fetch_data) -> QWidget:
pass