From d4e4af008a2f0968a3afd9a628faa6b849cce499 Mon Sep 17 00:00:00 2001
From: Tomas Pazderka <tomas.pazderka@nic.cz>
Date: Mon, 18 Jul 2016 13:54:31 +0200
Subject: [PATCH] Test for reverse_lazy
---
tests/file_storage/tests.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index b489c02..9dd4e57 100644
a
|
b
|
from django.core.files.storage import FileSystemStorage, get_storage_class
|
19 | 19 | from django.core.files.uploadedfile import ( |
20 | 20 | InMemoryUploadedFile, SimpleUploadedFile, TemporaryUploadedFile, |
21 | 21 | ) |
| 22 | from django.core.urlresolvers import NoReverseMatch, reverse_lazy |
22 | 23 | from django.test import ( |
23 | 24 | LiveServerTestCase, SimpleTestCase, TestCase, override_settings, |
24 | 25 | ) |
… |
… |
class FileStorageTests(unittest.TestCase):
|
98 | 99 | shutil.rmtree(self.temp_dir) |
99 | 100 | shutil.rmtree(self.temp_dir2) |
100 | 101 | |
| 102 | def test_lazy_init(self): |
| 103 | """ |
| 104 | Makes sure that init is lazy. |
| 105 | """ |
| 106 | storage = self.storage_class(location=self.temp_dir, |
| 107 | base_url=reverse_lazy('app:url')) |
| 108 | f = ContentFile('custom contents') |
| 109 | f.name = 'test.file' |
| 110 | storage.save(None, f) |
| 111 | |
| 112 | with self.assertRaises(NoReverseMatch): |
| 113 | storage.url(f.name) |
| 114 | |
101 | 115 | def test_empty_location(self): |
102 | 116 | """ |
103 | 117 | Makes sure an exception is raised if the location is empty |