示例#1
0
def test_not_valid_no_services(monkeypatch):
    env = {
        "SERVICE1_SERVICE_NAME": "group1",
        "SERVICE2_SERVICE_NAME": "group1",
        "SERVICE3_SERVICE_NAME": "group2",
    }

    monkeypatch.setattr(os, "environ", env)

    onion = Onions()
    onion._get_setup_from_env()

    with pytest.raises(Exception) as excinfo:
        onion.check_services()
        assert "has not ports set" in str(excinfo.value)
def test_not_valid_no_services(monkeypatch):
    env = {
        'SERVICE1_SERVICE_NAME': 'group1',
        'SERVICE2_SERVICE_NAME': 'group1',
        'SERVICE3_SERVICE_NAME': 'group2',
    }

    monkeypatch.setattr(os, 'environ', env)

    onion = Onions()
    onion._get_setup_from_env()

    with pytest.raises(Exception) as excinfo:
        onion.check_services()
        assert 'has not ports set' in str(excinfo.value)
示例#3
0
def test_not_valid_share_port(monkeypatch):
    env = {
        "SERVICE1_SERVICE_NAME": "group1",
        "SERVICE2_SERVICE_NAME": "group1",
        "SERVICE3_SERVICE_NAME": "group2",
        "SERVICE1_PORTS": "80:80",
        "SERVICE2_PORTS": "80:80,82:8000",
        "SERVICE3_PORTS": "80:unix://unix.socket",
    }

    monkeypatch.setattr(os, "environ", env)

    onion = Onions()
    onion._get_setup_from_env()

    with pytest.raises(Exception) as excinfo:
        onion.check_services()
        assert "Same port for multiple services" in str(excinfo.value)
def test_not_valid_share_port(monkeypatch):
    env = {
        'SERVICE1_SERVICE_NAME': 'group1',
        'SERVICE2_SERVICE_NAME': 'group1',
        'SERVICE3_SERVICE_NAME': 'group2',
        'SERVICE1_PORTS': '80:80',
        'SERVICE2_PORTS': '80:80,82:8000',
        'SERVICE3_PORTS': '80:unix://unix.socket',
    }

    monkeypatch.setattr(os, 'environ', env)

    onion = Onions()
    onion._get_setup_from_env()

    with pytest.raises(Exception) as excinfo:
        onion.check_services()
        assert 'Same port for multiple services' in str(excinfo.value)
示例#5
0
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