mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
clear the test cache at end of every test
This commit is contained in:
@@ -14,6 +14,8 @@ from awx.main.tests.factories import (
|
|||||||
create_workflow_job_template,
|
create_workflow_job_template,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from django.core.cache import cache
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
@@ -130,3 +132,10 @@ def mock_cache():
|
|||||||
|
|
||||||
return MockCache()
|
return MockCache()
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_runtest_teardown(item, nextitem):
|
||||||
|
# clear Django cache at the end of every test ran
|
||||||
|
# NOTE: this should not be memcache, see test_cache in test_env.py
|
||||||
|
# this is a local test cache, so we want every test to start with empty cache
|
||||||
|
cache.clear()
|
||||||
|
|
||||||
|
|||||||
@@ -75,9 +75,11 @@ def test_awx_task_env_validity(get, patch, admin, value, expected):
|
|||||||
url = reverse('api:setting_singleton_detail', kwargs={'category_slug': 'jobs'})
|
url = reverse('api:setting_singleton_detail', kwargs={'category_slug': 'jobs'})
|
||||||
patch(url, user=admin, data={'AWX_TASK_ENV': value}, expect=expected)
|
patch(url, user=admin, data={'AWX_TASK_ENV': value}, expect=expected)
|
||||||
|
|
||||||
|
resp = get(url, user=admin)
|
||||||
if expected == 200:
|
if expected == 200:
|
||||||
resp = get(url, user=admin)
|
|
||||||
assert resp.data['AWX_TASK_ENV'] == dict((k, str(v)) for k, v in value.items())
|
assert resp.data['AWX_TASK_ENV'] == dict((k, str(v)) for k, v in value.items())
|
||||||
|
else:
|
||||||
|
assert resp.data['AWX_TASK_ENV'] == dict()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
Reference in New Issue
Block a user