def test_create_node_may_fail(cl, client, has_conf): has_conf.return_value = False meta = {"cluster_name": "somevalue"} spec = {"external_id": "somemetavalue"} v1 = MagicMock() v1.create_node.side_effect = ApiException() client.CoreV1Api.return_value = v1 with pytest.raises(FailedActivity) as x: create_node(meta, spec) assert "Creating new node failed" in str(x)
def test_create_node(cl, client, has_conf): has_conf.return_value = False meta = {"cluster_name": "somevalue"} spec = {"external_id": "somemetavalue"} node = MagicMock() node.metadata.name = "mynode" v1 = MagicMock() v1.create_node.return_value = node client.CoreV1Api.return_value = v1 res = create_node(meta, spec) assert res.metadata.name == "mynode"