| 1 |
import django.test |
| 2 |
from django.urls import reverse |
| 3 |
|
| 4 |
from django_downloadview import assert_download_response |
| 5 |
|
| 6 |
|
| 7 |
class SimpleURLTestCase(django.test.TestCase): |
| 8 |
def test_download_response(self): |
| 9 |
"""'simple_url' serves 'hello-world.txt' from Github.""" |
| 10 |
url = reverse("http:simple_url") |
| 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 AvatarTestCase(django.test.TestCase): |
| 22 |
def test_download_response(self): |
| 23 |
"""HTTPDownloadView proxies Content-Type header.""" |
| 24 |
url = reverse("http:avatar_url") |
| 25 |
response = self.client.get(url) |
| 26 |
assert_download_response(self, response, mime_type="image/png") |