Commit 39309a95 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

tweaks

parent b64652d0
Loading
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -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

@@ -29,7 +30,7 @@ class CsstStatus(IntEnum):
    """

    # status list to be completed
    PERFECT = 0
    SUCCESS = 0
    WARNING = 1
    ERROR = 2

@@ -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
"""
+2 −1
Original line number Diff line number Diff line
@@ -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
@@ -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)