| 1 |
import django.test |
| 2 |
from django.urls import reverse |
| 3 |
|
| 4 |
from django_downloadview import assert_download_response |
| 5 |
|
| 6 |
|
| 7 |
class StaticPathTestCase(django.test.TestCase): |
| 8 |
def test_download_response(self): |
| 9 |
"""'static_path' serves 'fixtures/hello-world.txt'.""" |
| 10 |
url = reverse("path:static_path") |
| 11 |
response = self.client.get(url) |
| 12 |
assert_download_response( |
| 13 |
self, |
| 14 |
response, |
| 15 |
content="Hello world!\n", |
| 16 |
basename="hello-world.txt", |
| 17 |
mime_type="text/plain", |
| 18 |
) |
| 19 |
|
| 20 |
|
| 21 |
class DynamicPathTestCase(django.test.TestCase): |
| 22 |
def test_download_response(self): |
| 23 |
"""'dynamic_path' serves 'fixtures/{path}'.""" |
| 24 |
url = reverse("path:dynamic_path", kwargs={"path": "hello-world.txt"}) |
| 25 |
response = self.client.get(url) |
| 26 |
assert_download_response( |
| 27 |
self, |
| 28 |
response, |
| 29 |
content="Hello world!\n", |
| 30 |
basename="hello-world.txt", |
| 31 |
mime_type="text/plain", |
| 32 |
) |