From 8a56671eef15dde6fc50ae8c9da051d4bced85b3 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 20 Oct 2023 18:28:28 -0400 Subject: [PATCH] add unit tests for model container --- tests/test_abstract_model_container.py | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/test_abstract_model_container.py diff --git a/tests/test_abstract_model_container.py b/tests/test_abstract_model_container.py new file mode 100644 index 00000000..92547d9b --- /dev/null +++ b/tests/test_abstract_model_container.py @@ -0,0 +1,39 @@ +from collections.abc import Sequence + +from stpipe.container import AbstractModelContainer + + +class BadContainer(Sequence): + def __getitem__(self): + pass + + def __len__(self): + pass + + def save(self, path, save_model_func): + pass + + @staticmethod + def read_asn(filepath): + pass + + def from_asn(self, asn_data, asn_file_path=None): + pass + + +class GoodContainer(BadContainer): + @property + def crds_observatory(self): + return "" + + +def test_good_container(): + assert issubclass(GoodContainer, AbstractModelContainer) + gc = GoodContainer() + assert isinstance(gc, AbstractModelContainer) + + +def test_bad_container(): + assert not issubclass(BadContainer, AbstractModelContainer) + bc = BadContainer() + assert not isinstance(bc, AbstractModelContainer)