Ejemplo n.º 1
0
def test_environment_client_delete(mocker):
    mocker.patch.object(EnvironmentClient, "_delete_raw", return_value=None)

    client = EnvironmentClient(mocker.Mock())
    client.delete(PROJECT_ID, ENVIRONMENT_ID)

    EnvironmentClient._delete_raw.assert_called_once_with(
        "/project/{}/environment/{}".format(PROJECT_ID, ENVIRONMENT_ID))
Ejemplo n.º 2
0
def test_environment_client_list(mocker):
    mocker.patch.object(EnvironmentClient, "_get", return_value=[ENVIRONMENT])
    schema_mock = mocker.patch("faculty.clients.environment.EnvironmentSchema")

    client = EnvironmentClient(mocker.Mock())
    assert client.list(PROJECT_ID) == [ENVIRONMENT]

    schema_mock.assert_called_once_with(many=True)
    EnvironmentClient._get.assert_called_once_with(
        "/project/{}/environment".format(PROJECT_ID), schema_mock.return_value)
Ejemplo n.º 3
0
def test_environment_client_get(mocker):
    mocker.patch.object(EnvironmentClient, "_get", return_value=ENVIRONMENT)
    schema_mock = mocker.patch("faculty.clients.environment.EnvironmentSchema")

    client = EnvironmentClient(mocker.Mock())
    assert client.get(PROJECT_ID, ENVIRONMENT_ID) == ENVIRONMENT

    schema_mock.assert_called_once_with()
    EnvironmentClient._get.assert_called_once_with(
        "/project/{}/environment/{}".format(PROJECT_ID, ENVIRONMENT_ID),
        schema_mock.return_value,
    )
Ejemplo n.º 4
0
def test_environment_client_update(mocker):
    mocker.patch.object(EnvironmentClient, "_put_raw")
    mocker.patch.object(
        EnvironmentCreateUpdateSchema,
        "dump",
        return_value=ENVIRONMENT_CREATE_UPDATE_BODY,
    )

    client = EnvironmentClient(mocker.Mock())
    client.update(PROJECT_ID, ENVIRONMENT_ID, NAME, SPECIFICATION, DESCRIPTION)

    EnvironmentCreateUpdateSchema.dump.assert_called_once_with(
        ENVIRONMENT_CREATE_UPDATE)
    EnvironmentClient._put_raw.assert_called_once_with(
        "/project/{}/environment/{}".format(PROJECT_ID, ENVIRONMENT_ID),
        json=ENVIRONMENT_CREATE_UPDATE_BODY,
    )
Ejemplo n.º 5
0
def test_environment_client_create(mocker):
    mocker.patch.object(EnvironmentClient,
                        "_post",
                        return_value=ENVIRONMENT_CREATION_RESPONSE)
    mocker.patch.object(
        EnvironmentCreateUpdateSchema,
        "dump",
        return_value=ENVIRONMENT_CREATE_UPDATE_BODY,
    )
    schema_mock = mocker.patch(
        "faculty.clients.environment.EnvironmentCreationResponseSchema")

    client = EnvironmentClient(mocker.Mock())
    assert (client.create(
        PROJECT_ID, NAME, SPECIFICATION,
        description=DESCRIPTION) == ENVIRONMENT_CREATION_RESPONSE.id)
    EnvironmentCreateUpdateSchema.dump.assert_called_once_with(
        ENVIRONMENT_CREATE_UPDATE)
    EnvironmentClient._post.assert_called_once_with(
        "/project/{}/environment".format(PROJECT_ID),
        schema_mock.return_value,
        json=ENVIRONMENT_CREATE_UPDATE_BODY,
    )