Skip to content

test_create#

datacatalog_post_request#

Parameters:

Name Type Description Default
admin_client

Authenticated admin client

required
datacatalog_json

JSON-body for new data-catalog

required

Returns: Response object

Source code in tests/behave/features/datacatalog/test_create.py
@when("the user submits new data-catalog", target_fixture="datacatalog_post_request")
def datacatalog_post_request(admin_client, datacatalog_json, reference_data):
    """

    Args:
        admin_client (): Authenticated admin client
        datacatalog_json (): JSON-body for new data-catalog

    Returns: Response object

    """
    url = reverse("datacatalog-list")
    res = admin_client.post(url, datacatalog_json, content_type="application/json")
    logger.info(f"{datacatalog_json=}")
    logger.info(f"{res.content=}")
    return res

datacatalog_from_post_request#

Parameters:

Name Type Description Default
datacatalog_post_request

POST-request to datacatalog-api

required
datacatalog_json

POST-request body used to load instance from database

required

Returns:

Name Type Description
DataCatalog DataCatalog

instance created from POST-request

Source code in tests/behave/features/datacatalog/test_create.py
@when("new data-catalog is saved to database", target_fixture="datacatalog_from_post_request")
def datacatalog_from_post_request(datacatalog_post_request, datacatalog_json) -> DataCatalog:
    """

    Args:
        datacatalog_post_request (): POST-request to datacatalog-api
        datacatalog_json (): POST-request body used to load instance from database

    Returns:
         DataCatalog: instance created from POST-request

    """
    payload = json.loads(datacatalog_json)
    return DataCatalog.objects.get(title=payload["title"])

is_created_datacatalog_in_db#

Parameters:

Name Type Description Default
datacatalog_from_post_request

datacatalog fetched from the db after creation

required
Source code in tests/behave/features/datacatalog/test_create.py
@then("created data-catalog should be in database")
def is_created_datacatalog_in_db(datacatalog_from_post_request):
    """

    Args:
        datacatalog_from_post_request (): datacatalog fetched from the db after creation


    """
    assert bool(datacatalog_from_post_request) is True

is_response_create_ok#

Parameters:

Name Type Description Default
datacatalog_post_request

POST-request to datacatalog-api

required
Source code in tests/behave/features/datacatalog/test_create.py
@then("the user should get an OK create-response")
def is_response_create_ok(datacatalog_post_request):
    """

    Args:
        datacatalog_post_request (): POST-request to datacatalog-api


    """
    assert datacatalog_post_request.status_code == 201

test_datacatalog#

Parameters:

Name Type Description Default
datacatalog_json

POST-request body, used for assert validation

required
Source code in tests/behave/features/datacatalog/test_create.py
@scenario("datacatalog.feature", "Creating new data-catalog")
@pytest.mark.django_db
def test_datacatalog():
    """

    Args:
        datacatalog_json (): POST-request body, used for assert validation

    """
    pass