Пример #1
0
def test_computeDataReceivedCallback():
    callback_create = MagicMock()
    callback_update = MagicMock()
    cm = ComputeManager()
    cm.created_signal.connect(callback_create)
    cm.updated_signal.connect(callback_update)
    cm.computeDataReceivedCallback({
        "compute_id": "test",
        "name": "Test server",
        "connected": False,
        "protocol": "http",
        "host": "test.org",
        "port": 3080,
        "user": None,
        "cpu_usage_percent": None,
        "memory_usage_percent": None,
        "capabilities": {
            "test": "a"
        }
    })
    assert cm._computes["test"].name() == "Test server"
    assert cm._computes["test"].protocol() == "http"
    assert cm._computes["test"].host() == "test.org"
    assert cm._computes["test"].port() == 3080
    assert cm._computes["test"].user() is None
    assert cm._computes["test"].capabilities() == {"test": "a"}
    assert cm._computes["test"].connected() is False
    assert callback_create.called
    assert not callback_update.called

    # Data should be update
    cm.computeDataReceivedCallback({
        "compute_id": "test",
        "name": "Test Compute",
        "connected": True,
        "protocol": "http",
        "host": "test.org",
        "port": 3080,
        "user": None,
        "cpu_usage_percent": None,
        "memory_usage_percent": None,
        "capabilities": {
            "test": "a"
        }
    })
    assert cm._computes["test"].name() == "Test Compute"
    assert cm._computes["test"].connected()
    assert callback_update.called
Пример #2
0
def test_computeDataReceivedCallback():
    callback_create = MagicMock()
    callback_update = MagicMock()
    cm = ComputeManager()
    cm.created_signal.connect(callback_create)
    cm.updated_signal.connect(callback_update)
    cm.computeDataReceivedCallback({
        "compute_id": "test",
        "name": "Test server",
        "connected": False,
        "protocol": "http",
        "host": "test.org",
        "port": 3080,
        "user": None,
        "cpu_usage_percent": None,
        "memory_usage_percent": None,
        "capabilities": {"test": "a"}
    })
    assert cm._computes["test"].name() == "Test server"
    assert cm._computes["test"].protocol() == "http"
    assert cm._computes["test"].host() == "test.org"
    assert cm._computes["test"].port() == 3080
    assert cm._computes["test"].user() is None
    assert cm._computes["test"].capabilities() == {"test": "a"}
    assert cm._computes["test"].connected() is False
    assert callback_create.called
    assert not callback_update.called

    # Data should be update
    cm.computeDataReceivedCallback({
        "compute_id": "test",
        "name": "Test Compute",
        "connected": True,
        "protocol": "http",
        "host": "test.org",
        "port": 3080,
        "user": None,
        "cpu_usage_percent": None,
        "memory_usage_percent": None,
        "capabilities": {"test": "a"}
    })
    assert cm._computes["test"].name() == "Test Compute"
    assert cm._computes["test"].connected()
    assert callback_update.called
Пример #3
0
def test_getComputeRemote1X():
    """
    It should convert old server id
    """
    cm = ComputeManager()
    cm.computeDataReceivedCallback({
        "compute_id": "aaecb19d-5a32-4c18-ac61-f54f92a0f594",
        "name": "Test Compute",
        "connected": True,
        "protocol": "http",
        "host": "test.org",
        "port": 3080,
        "user": None,
        "cpu_usage_percent": None,
        "memory_usage_percent": None,
        "capabilities": {"test": "a"}
    })

    compute = cm.getCompute("aaecb19d-5a32-4c18-ac61-f54f92a0f594")
    assert cm.getCompute("http://test.org:3080") == compute
Пример #4
0
def test_getComputeRemote1X():
    """
    It should convert old server id
    """
    cm = ComputeManager()
    cm.computeDataReceivedCallback({
        "compute_id": "aaecb19d-5a32-4c18-ac61-f54f92a0f594",
        "name": "Test Compute",
        "connected": True,
        "protocol": "http",
        "host": "test.org",
        "port": 3080,
        "user": None,
        "cpu_usage_percent": None,
        "memory_usage_percent": None,
        "capabilities": {
            "test": "a"
        }
    })

    compute = cm.getCompute("aaecb19d-5a32-4c18-ac61-f54f92a0f594")
    assert cm.getCompute("http://test.org:3080") == compute