mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-10-31 22:24:30 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			725 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			725 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| # Copyright (C) 2020 by Animath
 | |
| # SPDX-License-Identifier: GPL-3.0-or-later
 | |
| 
 | |
| from django.conf import settings
 | |
| 
 | |
| _client = None
 | |
| 
 | |
| 
 | |
| def get_sympa_client():
 | |
|     global _client
 | |
|     if _client is None:
 | |
|         if settings.SYMPA_PASSWORD is not None:  # pragma: no cover
 | |
|             from sympasoap import Client
 | |
|             _client = Client("https://" + settings.SYMPA_URL)
 | |
|             _client.login(settings.SYMPA_EMAIL, settings.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
 |