Merge pull request #8039 from john-westcott-iv/transaction_check

Adding transaction to mock requests

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-08-30 17:54:07 +00:00 committed by GitHub
commit 07ebf677de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,8 @@ import pytest
from awx.main.tests.functional.conftest import _request
from awx.main.models import Organization, Project, Inventory, JobTemplate, Credential, CredentialType
from django.db import transaction
try:
import tower_cli # noqa
HAS_TOWER_CLI = True
@ -107,8 +109,9 @@ def run_module(request, collection_import):
kwargs_copy['data'][k] = v
# make request
rf = _request(method.lower())
django_response = rf(url, user=request_user, expect=None, **kwargs_copy)
with transaction.atomic():
rf = _request(method.lower())
django_response = rf(url, user=request_user, expect=None, **kwargs_copy)
# requests library response object is different from the Django response, but they are the same concept
# this converts the Django response object into a requests response object for consumption