ansible-collection-famedly-.../tests/unit/mock_nio/utils/ClientSimulator.py
2022-08-24 13:26:19 +02:00

21 lines
528 B
Python

import json
from typing import List
class ClientSimulator:
INITIAL_DATA = {'rooms': []}
def __init__(self, data: str = json.dumps(INITIAL_DATA)):
try:
self.data = json.loads(data)
except (json.JSONDecodeError, TypeError):
self.data = self.INITIAL_DATA
def export(self) -> str:
return json.dumps(self.data)
def join(self, room_id: str):
self.data['rooms'].append(room_id)
def get_joined_rooms(self) -> List[str]:
return self.data['rooms']