From feb9bcff4d3adbc7a884a908ccc5ec6b2518b328 Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Fri, 28 Aug 2020 12:43:33 -0400 Subject: [PATCH] Adding transaction to mock requests --- awx_collection/test/awx/conftest.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index 5db00d6325..10774b9b34 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -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