Loading csst_common/status.py +14 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ Modified-History: 2022-10-07, Bo Zhang, added Numpydoc docstring 2023-12-19, Bo Zhang, updated example """ from enum import IntEnum from typing import Optional, Any Loading @@ -29,7 +30,7 @@ class CsstStatus(IntEnum): """ # status list to be completed PERFECT = 0 SUCCESS = 0 WARNING = 1 ERROR = 2 Loading Loading @@ -57,25 +58,37 @@ class CsstResult: def __init__( self, status: CsstStatus = CsstStatus.ERROR, products: Optional[list[str]] = None, files: Optional[list[str]] = None, **output: Any, ): if files is None: files = [] if products is None: products = [] assert isinstance( status, CsstStatus ), "`status` should be a `csst_common.CsstStatus` type objects." assert isinstance( files, list ), "`files` should be a list of `str` type objects." assert isinstance( products, list ), "`products` should be a list of `str` type objects." for _ in products: assert isinstance( _, str ), "`products` should be a list of `str` type objects." for _ in files: assert isinstance(_, str), "`files` should be a list of `str` type objects." self.status: CsstStatus = status self.products: Optional[list] = products self.files: Optional[list] = files self.output: dict = output def __repr__(self): return f""" <CsstResult status={self.status}> - products: {self.products} \n - files: {self.files} - output: {self.output} \n """ tests/test_status.py +2 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ Modified-History: 2022-10-04, Bo Zhang, created, add CsstStatus test 2023-12-10, Bo Zhang, rename class """ import unittest from csst_common.status import CsstStatus Loading @@ -15,6 +16,6 @@ from csst_common.status import CsstStatus class TestCsstStatus(unittest.TestCase): def test_params(self): self.assertTrue(CsstStatus(0) == CsstStatus.PERFECT) self.assertTrue(CsstStatus(0) == CsstStatus.SUCCESS) self.assertTrue(CsstStatus(1) == CsstStatus.WARNING) self.assertTrue(CsstStatus(2) == CsstStatus.ERROR) Loading
csst_common/status.py +14 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ Modified-History: 2022-10-07, Bo Zhang, added Numpydoc docstring 2023-12-19, Bo Zhang, updated example """ from enum import IntEnum from typing import Optional, Any Loading @@ -29,7 +30,7 @@ class CsstStatus(IntEnum): """ # status list to be completed PERFECT = 0 SUCCESS = 0 WARNING = 1 ERROR = 2 Loading Loading @@ -57,25 +58,37 @@ class CsstResult: def __init__( self, status: CsstStatus = CsstStatus.ERROR, products: Optional[list[str]] = None, files: Optional[list[str]] = None, **output: Any, ): if files is None: files = [] if products is None: products = [] assert isinstance( status, CsstStatus ), "`status` should be a `csst_common.CsstStatus` type objects." assert isinstance( files, list ), "`files` should be a list of `str` type objects." assert isinstance( products, list ), "`products` should be a list of `str` type objects." for _ in products: assert isinstance( _, str ), "`products` should be a list of `str` type objects." for _ in files: assert isinstance(_, str), "`files` should be a list of `str` type objects." self.status: CsstStatus = status self.products: Optional[list] = products self.files: Optional[list] = files self.output: dict = output def __repr__(self): return f""" <CsstResult status={self.status}> - products: {self.products} \n - files: {self.files} - output: {self.output} \n """
tests/test_status.py +2 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ Modified-History: 2022-10-04, Bo Zhang, created, add CsstStatus test 2023-12-10, Bo Zhang, rename class """ import unittest from csst_common.status import CsstStatus Loading @@ -15,6 +16,6 @@ from csst_common.status import CsstStatus class TestCsstStatus(unittest.TestCase): def test_params(self): self.assertTrue(CsstStatus(0) == CsstStatus.PERFECT) self.assertTrue(CsstStatus(0) == CsstStatus.SUCCESS) self.assertTrue(CsstStatus(1) == CsstStatus.WARNING) self.assertTrue(CsstStatus(2) == CsstStatus.ERROR)