You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the unit tests DATA variables are list[AntaUnitTest]. This has led to duplicates in the past.
class AntaUnitTest(TypedDict):
"""The parameters required for a unit test of an AntaTest subclass."""
name: str
test: type[AntaTest]
inputs: NotRequired[dict[str, Any]]
eos_data: list[dict[str, Any] | str]
expected: Expected
We should refactor the DATA variables to be dict[Tuple[type[AntaTest], str], AntaUnitTest] instead where AntaUnitTest is:
class AntaUnitTest(TypedDict):
"""The parameters required for a unit test of an AntaTest subclass."""
inputs: NotRequired[dict[str, Any]]
eos_data: list[dict[str, Any] | str]
expected: Expected
DATA: list[AntaUnitTest] = [
{
# Arbitrary test name."name": "success",
# Must be an AntaTest subclass definition"test": VerifyUptime,
# JSON output of the 'show uptime' EOS command as defined in VerifyUptime.commands"eos_data": [{"upTime": 1186689.15, "loadAvg": [0.13, 0.12, 0.09], "users": 1, "currentTime": 1683186659.139859}],
# Dictionary to instantiate VerifyUptime.Input"inputs": {"minimum": 666},
# Expected test result"expected": {"result": "success"},
},
{
"name": "failure",
"test": VerifyUptime,
"eos_data": [{"upTime": 665.15, "loadAvg": [0.13, 0.12, 0.09], "users": 1, "currentTime": 1683186659.139859}],
"inputs": {"minimum": 666},
# If the test returns messages, it needs to be expected otherwise test will fail.# The expected message can be a substring of the actual message."expected": {"result": "failure", "messages": ["Device uptime is 665.15 seconds"]},
},
]
DATA: dict[Tuple[type[AntaTest], str], AntaUnitTest] = {
(VerifyUptime, "success"): { # First element is an AntaTest subclass definition and the second an arbitrary test name.# JSON output of the 'show uptime' EOS command as defined in VerifyUptime.commands"eos_data": [{"upTime": 1186689.15, "loadAvg": [0.13, 0.12, 0.09], "users": 1, "currentTime": 1683186659.139859}],
"inputs": {"minimum": 666}, # Dictionary to instantiate VerifyUptime.Input# Expected test result"expected": {"result": "success"},
},
(VerifyUptime, "failure"): {
"eos_data": [{"upTime": 665.15, "loadAvg": [0.13, 0.12, 0.09], "users": 1, "currentTime": 1683186659.139859}],
"inputs": {"minimum": 666},
# If the test returns messages, it needs to be expected otherwise test will fail.# The expected message can be a substring of the actual message."expected": {"result": "failure", "messages": ["Device uptime is 665.15 seconds"]},
},
}
The text was updated successfully, but these errors were encountered:
Currently, the unit tests DATA variables are
list[AntaUnitTest]
. This has led to duplicates in the past.We should refactor the DATA variables to be
dict[Tuple[type[AntaTest], str], AntaUnitTest]
instead whereAntaUnitTest
is:The text was updated successfully, but these errors were encountered: