-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timestamp in export filename, and require auth
- Loading branch information
Showing
3 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,4 +215,4 @@ | |
CSP_FONT_SRC = ("'self'",) | ||
CSP_EXCLUDE_URL_PREFIXES = ("/admin",) | ||
|
||
|
||
LOGIN_URL = "/admin/login/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
from django.test import TestCase | ||
from django.core.urlresolvers import reverse | ||
from django.contrib.auth.models import User | ||
from rest_framework import status | ||
import datetime | ||
|
||
|
||
class ExportViewTestCases(TestCase): | ||
def test_export_view(self): | ||
|
||
@classmethod | ||
def setUpTestData(cls): | ||
cls.superuser = User.objects.create( | ||
id=100, | ||
password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', | ||
last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), | ||
is_superuser=True, username='super', first_name='Super', | ||
last_name='User', email='super@example.com', is_staff=True, | ||
is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) | ||
) | ||
|
||
def test_export_view(self): | ||
self.client.force_login(self.superuser) | ||
response = self.client.get(reverse('export')) | ||
self.assertTemplateNotUsed(response, 'index.html') | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertRegexpMatches(response['Content-Disposition'], r'^attachment;') | ||
self.assertRegexpMatches(response['Content-Type'], r'spreadsheet') | ||
self.assertRegexpMatches(response['Content-Disposition'], r'filename=.*\.xlsx?') | ||
self.assertRegexpMatches(response['Content-Type'], r'spreadsheet|excel') | ||
|
||
def test_export_view_noauth(self): | ||
response = self.client.get(reverse('export')) | ||
self.assertEqual(response.status_code, status.HTTP_302_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters