forked from jazzband/django-newsletter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed addresses serialization with JSON-based sessions
Fixes jazzband#104.
- Loading branch information
Showing
6 changed files
with
82 additions
and
14 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
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name;email | ||
John Smith;[email protected] | ||
Jill Martin;[email protected] |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
|
||
from django.core.urlresolvers import reverse | ||
from django.test import TestCase | ||
|
||
from newsletter import admin # Triggers model admin registration | ||
from newsletter.models import Newsletter | ||
from newsletter.utils import get_user_model | ||
|
||
test_files_dir = os.path.join(os.path.dirname(__file__), 'files') | ||
|
||
|
||
class AdminTestCase(TestCase): | ||
def setUp(self): | ||
super(AdminTestCase, self).setUp() | ||
User = get_user_model() | ||
self.password = 'johnpassword' | ||
self.admin_user = User.objects.create_superuser( | ||
'john', '[email protected]', self.password | ||
) | ||
self.client.login(username=self.admin_user.username, password=self.password) | ||
self.newsletter = Newsletter.objects.create( | ||
sender='Test Sender', title='Test Newsletter', | ||
slug='test-newsletter', visible=True, email='[email protected]', | ||
) | ||
|
||
def test_admin_import_subscribers(self): | ||
""" | ||
Import process of a CSV file containing subscription addresses from | ||
the admin site. | ||
""" | ||
import_url = reverse('admin:newsletter_subscription_import') | ||
response = self.client.get(import_url) | ||
self.assertContains(response, "<h1>Import addresses</h1>") | ||
|
||
with open(os.path.join(test_files_dir, 'addresses.csv'), 'rb') as fh: | ||
response = self.client.post(import_url, { | ||
'newsletter': self.newsletter.pk, | ||
'address_file': fh, | ||
'ignore_errors': '', | ||
}, follow=True) | ||
self.assertContains(response, "<h1>Confirm import</h1>") | ||
|
||
import_confirm_url = reverse( | ||
'admin:newsletter_subscription_import_confirm' | ||
) | ||
response = self.client.post( | ||
import_confirm_url, {'confirm': True}, follow=True | ||
) | ||
self.assertContains( | ||
response, | ||
"2 subscriptions have been successfully added." | ||
) | ||
self.assertEqual(self.newsletter.subscription_set.count(), 2) |
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
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,6 +1,8 @@ | ||
from django.conf.urls import include, url | ||
from django.contrib import admin | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^admin/', admin.site.urls), | ||
url(r'^newsletter/', include('newsletter.urls')), | ||
] |