Source code for features.steps.r_004_steps

"""Python steps file for R_004."""

import logging
from typing import Any

from behave import given, runner, then, when

[docs] logger = logging.getLogger(__name__)
@when('the API client sends a POST request to "/api/identities" with the following payload:')
[docs] def step_post_identity(context: runner.Context, payload: Any) -> None: # noqa: ARG001 """Sends a POST request to the REST API to create a new identity. Args: context (runner.Context): Behave context. payload (Any): The payload containing the identity fields. """ msg = 'Step not implemented: POST request to create an identity.' raise AssertionError(msg)
@when('the API client sends a GET request to "/api/identities/<identifier>"')
[docs] def step_get_identity(context: runner.Context, identifier: str) -> None: # noqa: ARG001 """Sends a GET request to the REST API to retrieve an identity by its identifier. Args: context (runner.Context): Behave context. identifier (str): The unique identifier of the identity. """ msg = 'Step not implemented: GET request to retrieve an identity.' raise AssertionError(msg)
@when('the API client sends a PUT request to "/api/identities/<identifier>" with the following payload:')
[docs] def step_put_identity(context: runner.Context, identifier: str, payload: Any) -> None: # noqa: ARG001 """Sends a PUT request to update an existing identity. Args: context (runner.Context): Behave context. identifier (str): The unique identifier of the identity. payload (Any): The payload containing the updated identity fields. """ msg = 'Step not implemented: PUT request to update an identity.' raise AssertionError(msg)
@when('the API client sends a DELETE request to "/api/identities/<identifier>"')
[docs] def step_delete_identity(context: runner.Context, identifier: str) -> None: # noqa: ARG001 """Sends a DELETE request to remove an identity by its identifier. Args: context (runner.Context): Behave context. identifier (str): The unique identifier of the identity. """ msg = 'Step not implemented: DELETE request to remove an identity.' raise AssertionError(msg)
@when('the API client sends a GET request to "/api/identities" without authentication')
[docs] def step_get_without_auth(context: runner.Context) -> None: # noqa: ARG001 """Sends a GET request to the REST API without authentication. Args: context (runner.Context): Behave context. """ msg = 'Step not implemented: Unauthorized GET request.' raise AssertionError(msg)
@then('the response payload should include the created identity with:')
[docs] def step_verify_created_identity(context: runner.Context, payload: Any) -> None: # noqa: ARG001 """Verifies the response payload includes the expected fields for a newly created identity. Args: context (runner.Context): Behave context. payload (Any): Expected identity fields. """ msg = 'Step not implemented: Verify response payload for created identity.' raise AssertionError(msg)
@then('the response payload should include the identity with:')
[docs] def step_verify_retrieved_identity(context: runner.Context, payload: Any) -> None: # noqa: ARG001 """Verifies the response payload includes the expected fields for the retrieved identity. Args: context (runner.Context): Behave context. payload (Any): Expected identity fields. """ msg = 'Step not implemented: Verify response payload for retrieved identity.' raise AssertionError(msg)
@given('the identity {identity} exists')
[docs] def step_identity_exists(context: runner.Context, identity: str) -> None: # noqa: ARG001 """Ensures the identity exists. Args: context (runner.Context): Behave context. identity (str): The identity name. """ msg = 'STEP: Given the identity {identity} exists' raise AssertionError(msg)
@when('the API client sends a GET request to "/api/identities/{identity}"')
[docs] def step_get_identity_by_name(context: runner.Context, identity: str) -> None: # noqa: ARG001 """Sends a GET request for an identity by name. Args: context (runner.Context): Behave context. identity (str): The identity name. """ msg = f'STEP: When the API client sends a GET request to "/api/identities/{identity}"' raise AssertionError(msg)
@when('the API client sends a PUT request to "/api/identities/{identity}" with the following payload:')
[docs] def step_put_identity_by_name(context: runner.Context, identity: str, payload: Any) -> None: # noqa: ARG001 """Updates an identity by name. Args: context (runner.Context): Behave context. identity (str): The identity name. payload (Any): Updated identity data. """ msg = ( f'STEP: When the API client sends a PUT request to "/api/identities/{identity}" with the following payload: ' f'{payload}' ) raise AssertionError(msg)
@then('the response payload should include the updated identity with:')
[docs] def step_verify_updated_identity(context: runner.Context, payload: Any) -> None: # noqa: ARG001 """Verifies the response payload contains the updated identity. Args: context (runner.Context): Behave context. payload (Any): Expected updated identity data. """ msg = f'STEP: Then the response payload should include the updated identity with: {payload}' raise AssertionError(msg)
@when('the API client sends a DELETE request to "/api/identities/{identity}"')
[docs] def step_delete_identity_by_name(context: runner.Context, identity: str) -> None: # noqa: ARG001 """Deletes an identity by name. Args: context (runner.Context): Behave context. identity (str): The identity name. """ msg = f'STEP: When the API client sends a DELETE request to "/api/identities/{identity}"' raise AssertionError(msg)
@then('the identity {identity} should no longer exist')
[docs] def step_verify_identity_deletion(context: runner.Context, identity: str) -> None: # noqa: ARG001 """Checks if an identity no longer exists. Args: context (runner.Context): Behave context. identity (str): The identity name. """ msg = f'STEP: Then the identity {identity} should no longer exist' raise AssertionError(msg)