api_client = <rest_framework.test.APIClient object at 0x7f862786f7f0>
regular_user = <User: johndoe>
add_forge_data = {'forge_contact_comment': 'user marked as owner in forge members', 'forge_contact_email': 'admin@gitea.example.org', 'forge_contact_name': 'gitea.example.org admin', 'forge_type': 'gitea', ...}
@pytest.mark.django_db(transaction=True, reset_sequences=True)
@pytest.mark.parametrize(
"add_forge_data",
[
ADD_FORGE_DATA_FORGE1,
ADD_FORGE_DATA_FORGE2,
ADD_FORGE_DATA_FORGE3,
ADD_FORGE_DATA_FORGE4,
],
)
def test_add_forge_request_create_success_post(
api_client, regular_user, add_forge_data
):
api_client.force_login(regular_user)
url = reverse("api-1-add-forge-request-create")
date_before = datetime.datetime.now(tz=datetime.timezone.utc)
resp = check_api_post_response(
api_client,
url,
data=add_forge_data,
status_code=201,
)
date_after = datetime.datetime.now(tz=datetime.timezone.utc)
consent = add_forge_data["submitter_forward_username"]
# map the expected result with what's expectedly read from the db to ease comparison
expected_consent_bool = consent == "on" if isinstance(consent, str) else consent
> assert resp.data == {
**add_forge_data,
"id": resp.data["id"],
"status": "PENDING",
"submission_date": resp.data["submission_date"],
"submitter_name": regular_user.username,
"submitter_email": regular_user.email,
"submitter_forward_username": expected_consent_bool,
}
E AssertionError: assert {'id': 1, 'mo...orge members'} == {'forge_conta... 'gitea', ...}
E Omitting 11 identical items, use -vv to show
E Left contains 2 more items:
E {'last_modified_date': '2022-05-02T11:09:17.270356Z', 'moderator': 'None'}
E Full diff:
E {
E 'forge_contact_comment': 'user marked as owner in forge members',
E 'forge_contact_email': 'admin@gitea.example.org',...
E
E ...Full output truncated (13 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_add_forge_now.py:109: AssertionError
TEST RESULT
TEST RESULT
- Run At
- May 2 2022, 1:32 PM