Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Use a tmpdir for file upload storage #323

Merged
merged 1 commit into from
Oct 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tests/test_web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ def _fake_redis_queue():
return Mock(fetch_job=Mock(return_value=None))


@pytest.fixture
def tmp_media_root(tmpdir, settings):
"""For each test, create a temporary directory where its media (including
any uploaded files) will be stored. The `tmpdir` fixture creates and tears
down a temporary directory; the `settings` fixture allows us to easily set
(and automatically unset) any Django setting"""
settings.MEDIA_ROOT = str(tmpdir)


@patch("django_rq.enqueue", _fake_redis_job)
@patch("django_rq.get_queue", _fake_redis_queue)
class PipelineJobTestCase(APITestCase):
Expand Down Expand Up @@ -134,8 +143,8 @@ def test_create_delete_and_read(self):
self.assertEqual(0, len(response.data))


@pytest.mark.usefixtures("tmp_media_root")
class RegulationFileTestCase(APITestCase):

def __init__(self, *args, **kwargs):
self.file_contents = "123"
self.hashed_contents = None
Expand Down Expand Up @@ -221,6 +230,7 @@ def test_create_and_read_and_delete(self):
self.assertEquals(0, len(data))


@pytest.mark.usefixtures("tmp_media_root")
@patch("django_rq.enqueue", _fake_redis_job)
@patch("django_rq.get_queue", _fake_redis_queue)
class ProposalPipelineTestCase(APITestCase):
Expand Down