-
Notifications
You must be signed in to change notification settings - Fork 282
/
Copy pathtest_result.py
42 lines (30 loc) · 1.07 KB
/
test_result.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
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
import logging
from typing import Callable
class TestResult:
component: str
config: dict
status: int
def __init__(self, component: str, config: dict, status: int) -> None:
self.component = component
self.config = config
self.status = status
@property
def __test_result(self) -> str:
return "PASS" if self.status == 0 else "FAIL"
def __str__(self) -> str:
return "| {:20s} | {:20s} | {:5s} |".format(self.component, self.config, self.__test_result)
def __logger(self) -> Callable:
return logging.info if self.status == 0 else logging.error
def log(self, result: str) -> None:
logger = self.__logger()
logger(result)
@property
def failed(self) -> bool:
return True if self.status != 0 else False
TestResult.__test__ = False # type:ignore