示例#1
0
def test_create_floatingips_state_is_actual():
    client = get_mocked_client()
    module = get_mocked_module()

    @create_object('floatingip')
    def function_that_return_fips_params(module, client):
        return [], False, "Desirable state already in project"

    output = function_that_return_fips_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert output == params.ACTUAL_STATE
示例#2
0
def test_create_project():
    client = get_mocked_client()
    module = get_mocked_module()

    @create_object('project')
    def function_that_return_project_params(module, client):
        return params.PROJECT_OBJECT, True, params.PROJECT_CREATED_MSG

    output = function_that_return_project_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert output == params.PROJECT_CREATED
示例#3
0
def test_update_project_name():
    client = get_mocked_client()
    module = get_mocked_module()

    @update_object
    def function_that_return_project_params(module, client):
        return True, "Project updated"

    output = function_that_return_project_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert output == params.PROJECT_UPDATED
示例#4
0
def test_create_floatinips():
    client = get_mocked_client()
    module = get_mocked_module()

    @create_object('floatingip')
    def function_that_return_fips_params(module, client):
        return params.FLOATING_IPS_RESP, True, params.FLOATING_IP_CREATED_MSG

    output = function_that_return_fips_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert output == params.FLOATING_IP_CREATED
示例#5
0
def test_update_project_name_existed():
    client = get_mocked_client()
    module = get_mocked_module()

    @update_object
    def function_that_return_project_params(module, client):
        return False, "Project with such name already exists"

    output = function_that_return_project_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert output == params.PROJECT_EXISTS
示例#6
0
def test_delete_object():
    client = get_mocked_client()
    module = get_mocked_module()

    @delete_object
    def function_that_delete_object(module, client):
        pass

    output = function_that_delete_object(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert output == params.DELETED
def test_get_licenses_list():
    client = get_mocked_client()
    module = get_mocked_module()

    @get_object('license')
    def function_that_return_license_params(module, client):
        return params.LICENSES_LIST

    output = function_that_return_license_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert len(output["licenses"]) == len(params.LICENSES_LIST)
def test_get_project_list():
    client = get_mocked_client()
    module = get_mocked_module()

    @get_object('project')
    def function_that_return_project_params(module, client):
        return params.PROJECT_LIST

    output = function_that_return_project_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert len(output["projects"]) == len(params.PROJECT_LIST)
def test_get_floatingips_list():
    client = get_mocked_client()
    module = get_mocked_module()

    @get_object('floatingip')
    def function_that_return_fips_params(module, client):
        return params.FLOATING_IPS_LIST

    output = function_that_return_fips_params(module, client)

    assert module.fail_json.called is False
    assert module.exit_json.called is True
    assert module.exit_json.call_count == 1
    assert output is not None
    assert len(output["floatingips"]) == len(params.FLOATING_IPS_LIST)