Ejemplo n.º 1
0
def test_deleteCompute(controller):
    callback_delete = MagicMock()
    cm = ComputeManager()
    cm.deleted_signal.connect(callback_delete)
    compute = cm.getCompute("test")
    assert cm.getCompute("test") == compute
    cm.deleteCompute("test")
    assert "test" not in cm._computes
    assert callback_delete.called
    controller._http_client.createHTTPQuery.assert_called_with("DELETE", "/computes/test", None)
Ejemplo n.º 2
0
def test_deleteCompute(controller):
    callback_delete = MagicMock()
    cm = ComputeManager()
    cm.deleted_signal.connect(callback_delete)
    compute = cm.getCompute("test")
    assert cm.getCompute("test") == compute
    cm.deleteCompute("test")
    assert "test" not in cm._computes
    assert callback_delete.called
    controller._http_client.createHTTPQuery.assert_called_with(
        "DELETE", "/computes/test", None)
Ejemplo n.º 3
0
def test_updateList_deleted(controller):
    cm = ComputeManager()
    computes = []
    computes.append(cm.getCompute("test1"))
    computes.append(cm.getCompute("test2"))
    # This server new to be deleted because exist in compute manager
    # but not in setting list
    cm.getCompute("test3")
    cm.updateList(computes)
    assert "test1" in cm._computes
    assert "test2" in cm._computes
    assert "test3" not in cm._computes
Ejemplo n.º 4
0
def test_updateList_deleted(controller):
    cm = ComputeManager()
    computes = []
    computes.append(cm.getCompute("test1"))
    computes.append(cm.getCompute("test2"))
    # This server new to be deleted because exist in compute manager
    # but not in setting list
    cm.getCompute("test3")
    cm.updateList(computes)
    assert "test1" in cm._computes
    assert "test2" in cm._computes
    assert "test3" not in cm._computes
Ejemplo n.º 5
0
def test_updateList_no_change(controller):
    cm = ComputeManager()
    computes = []
    compute = copy.copy(cm.getCompute("test1"))
    computes.append(compute)
    controller._http_client = MagicMock()
    cm.updateList(computes)
    assert not controller._http_client.createHTTPQuery.called
Ejemplo n.º 6
0
def test_updateList_no_change(controller):
    cm = ComputeManager()
    computes = []
    compute = copy.copy(cm.getCompute("test1"))
    computes.append(compute)
    controller._http_client = MagicMock()
    cm.updateList(computes)
    assert not controller._http_client.createHTTPQuery.called
Ejemplo n.º 7
0
def test_updateList_updated(controller):
    cm = ComputeManager()
    computes = []
    compute = copy.copy(cm.getCompute("test1"))
    computes.append(compute)
    compute.setName("TEST2")
    cm.updateList(computes)
    assert cm._computes["test1"].name() == "TEST2"
    controller._http_client.createHTTPQuery.assert_called_with("PUT", "/computes/test1", None, body=compute.__json__())
Ejemplo n.º 8
0
def test_updateList_updated(controller):
    cm = ComputeManager()
    computes = []
    compute = copy.copy(cm.getCompute("test1"))
    computes.append(compute)
    compute.setName("TEST2")
    cm.updateList(computes)
    assert cm._computes["test1"].name() == "TEST2"
    controller._http_client.createHTTPQuery.assert_called_with(
        "PUT", "/computes/test1", None, body=compute.__json__())
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
0
def test_getCompute():
    cm = ComputeManager()
    compute = cm.getCompute("local")
    assert cm.getCompute("local") == compute
Ejemplo n.º 12
0
def test_getCompute():
    cm = ComputeManager()
    compute = cm.getCompute("local")
    assert cm.getCompute("local") == compute