Adding transaction to mock requests

This commit is contained in:
John Westcott IV
2020-08-28 12:43:33 -04:00
parent fe5fb0c523
commit feb9bcff4d

View File

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