From c29ed171b44ec1b99995f09149b17279f8c0216c Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 9 Oct 2020 14:06:07 +0200 Subject: [PATCH] Simulate a fake Sympa client to run tests --- corres2math/lists.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/corres2math/lists.py b/corres2math/lists.py index 187f4e2..9804ac6 100644 --- a/corres2math/lists.py +++ b/corres2math/lists.py @@ -8,6 +8,17 @@ _client = None def get_sympa_client() -> Client: global _client if _client is None: - _client = Client("https://" + os.getenv("SYMPA_URL")) - _client.login(os.getenv("SYMPA_EMAIL"), os.getenv("SYMPA_PASSWORD")) + if os.getenv("SYMPA_PASSWORD", None) is not None: + _client = Client("https://" + os.getenv("SYMPA_URL")) + _client.login(os.getenv("SYMPA_EMAIL"), os.getenv("SYMPA_PASSWORD")) + else: + _client = FakeSympaSoapClient() return _client + + +class FakeSympaSoapClient: + """ + Simulate a Sympa Soap client to run tests, if no Sympa instance is connected. + """ + def __getattribute__(self, item): + return lambda *args, **kwargs: None