2020-10-09 11:49:09 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
_client = None
|
|
|
|
|
|
|
|
|
2020-10-09 12:18:27 +00:00
|
|
|
def get_sympa_client():
|
2020-10-09 11:49:09 +00:00
|
|
|
global _client
|
|
|
|
if _client is None:
|
2020-11-03 18:13:33 +00:00
|
|
|
if os.getenv("SYMPA_PASSWORD", None) is not None: # pragma: no cover
|
2020-10-09 12:18:27 +00:00
|
|
|
from sympasoap import Client
|
2020-10-09 12:06:07 +00:00
|
|
|
_client = Client("https://" + os.getenv("SYMPA_URL"))
|
|
|
|
_client.login(os.getenv("SYMPA_EMAIL"), os.getenv("SYMPA_PASSWORD"))
|
|
|
|
else:
|
|
|
|
_client = FakeSympaSoapClient()
|
2020-10-09 11:49:09 +00:00
|
|
|
return _client
|
2020-10-09 12:06:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|