openapi: Refactor hacky openAPI curl test.

Fixes #17795

In PR #17014, we added support for deactivate-own-user.
And while doing so, we first deactivated the client and
then reactivated it. But this implementation is a bit
hacky.

So, to fix this, we're now deactivating a test_user so that
we don't have to reactivate it. We did so by changing the value
of authentication_line.

As we want to keep endpoint code out of the
“test_curl_examples”, we changed the value of
authentication_line in `curl_param_value_generators.py`.

To work this out, we create a new global variable named
AUTHENTICATION_LINE in “curl_param_value_generators.py”
and change its value in function “deactivate_own_user” and
to use this change in “test_curl_examples,” we import
AUTHENTICATION_LINE.

AUTHENTICATION_LINE is of list data type because we want a
pointer to original mutable object so that changes made during
run time show across the module. Another way to do this is to change
the way we import variable, but that will be inconsistent to
the way we had in all other files.

To remove confusion between AUTHENTICATION_LINE and
authentication_line we renamed authentication_line
to default_authentication_line.
This commit is contained in:
100RABHpy
2021-04-02 15:58:50 +05:30
committed by Tim Abbott
parent 37b4d07934
commit 21be0ef445
3 changed files with 36 additions and 20 deletions

View File

@@ -106,7 +106,7 @@ with test_server_running(
)
test_the_api(client, nonadmin_client, owner_client)
test_generated_curl_examples_for_success(client, owner_client)
test_generated_curl_examples_for_success(client)
test_js_bindings(client)
# Test error payloads