def test_json(monkeypatch): env = { "SERVICE1_SERVICE_NAME": "group1", "SERVICE2_SERVICE_NAME": "group1", "SERVICE3_SERVICE_NAME": "group2", "SERVICE1_PORTS": "80:80", "SERVICE2_PORTS": "81:80,82:8000", "SERVICE3_PORTS": "80:unix://unix.socket", } monkeypatch.setattr(os, "environ", env) onion = Onions() onion._get_setup_from_env() onion.check_services() jsn = json.loads(onion.to_json()) assert len(jsn) == 2 assert len(jsn["group1"]) == 3 assert len(jsn["group2"]) == 1
def test_json(monkeypatch): env = { 'SERVICE1_SERVICE_NAME': 'group1', 'SERVICE2_SERVICE_NAME': 'group1', 'SERVICE3_SERVICE_NAME': 'group2', 'SERVICE1_PORTS': '80:80', 'SERVICE2_PORTS': '81:80,82:8000', 'SERVICE3_PORTS': '80:unix://unix.socket', } monkeypatch.setattr(os, 'environ', env) onion = Onions() onion._get_setup_from_env() onion.check_services() jsn = json.loads(onion.to_json()) assert len(jsn) == 2 assert len(jsn['group1']) == 3 assert len(jsn['group2']) == 1