Skip to content

Commit e691f28

Browse files
committed
Add view tests
Fix `render_to_string()` kwarg. Add django-test-plus for testing Update version
1 parent 5c2efe7 commit e691f28

File tree

7 files changed

+65
-16
lines changed

7 files changed

+65
-16
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ Fragment displays how many invites a particular user has.
324324

325325
## Change Log
326326

327+
### 6.1.2
328+
329+
* Replace deprecated `context_instance=RequestContext(r)` kwarg with `request=r`
330+
* Add InviteView smoke tests
331+
327332
### 6.1.1
328333

329334
* Add django>=1.11 to requirements

pinax/invitations/tests/tests.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from django.contrib.auth.models import User
22
from django.core.management import call_command
3-
from django.test import TestCase
43

54
from account.models import SignupCode
65
from pinax.invitations.forms import InviteForm
76
from pinax.invitations.models import InvitationStat, JoinInvitation
7+
from test_plus.test import TestCase
88

99

1010
class TestsJoinInvitation(TestCase):
@@ -73,3 +73,26 @@ def test_already_invited(self):
7373
}
7474
form = InviteForm(user=from_user, data=form_data)
7575
self.assertFalse(form.is_valid())
76+
77+
78+
class ViewTests(TestCase):
79+
80+
def test_invite_view(self):
81+
"""verify no errors when posting good form data"""
82+
user = self.make_user("amy")
83+
InvitationStat.add_invites(2)
84+
post_data = {
85+
"email_address": "[email protected]"
86+
}
87+
with self.login(user):
88+
self.post("pinax_invitations:invite", data=post_data)
89+
self.response_200()
90+
91+
def test_invite_view_bad_data(self):
92+
"""verify no errors when posting bad data"""
93+
user = self.make_user("sandee")
94+
post_data = {
95+
}
96+
with self.login(user):
97+
self.post("pinax_invitations:invite", data=post_data)
98+
self.response_200()

pinax/invitations/tests/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.conf.urls import include, url
22

33
urlpatterns = [
4+
url(r"^account", include("account.urls")),
45
url(r"^", include("pinax.invitations.urls", namespace="pinax_invitations")),
56
]

pinax/invitations/views.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ def get_data(self, form):
2929
self.invite_form_fragment, {
3030
"form": form,
3131
"user": self.request.user
32-
}, context_instance=RequestContext(self.request)
32+
}, request=self.request
3333
),
3434
"fragments": {
3535
self.invites_remaining_fragment_selector: render_to_string(
3636
self.invites_remaining_fragment, {
3737
"invites_remaining": self.request.user.invitationstat.invites_remaining()
38-
}, context_instance=RequestContext(self.request)
38+
}, request=self.request
3939
),
4040
self.invited_fragment_selector: render_to_string(
4141
self.invited_fragment, {
4242
"invited_list": self.request.user.invites_sent.all()
43-
}, context_instance=RequestContext(self.request)
43+
}, request=self.request
4444
)
4545
}
4646
}

runtests.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@
66

77
from django.conf import settings
88

9-
109
DEFAULT_SETTINGS = dict(
1110
INSTALLED_APPS=[
1211
"django.contrib.auth",
1312
"django.contrib.contenttypes",
13+
"django.contrib.sessions",
1414
"django.contrib.sites",
1515
"account",
16+
"bootstrapform",
1617
"pinax.invitations",
17-
"pinax.invitations.tests"
18+
"pinax.invitations.tests",
19+
"pinax.templates",
20+
],
21+
MIDDLEWARE=[
22+
"django.contrib.sessions.middleware.SessionMiddleware",
23+
"django.contrib.auth.middleware.AuthenticationMiddleware",
1824
],
1925
DATABASES={
2026
"default": {
@@ -25,6 +31,18 @@
2531
SITE_ID=1,
2632
ROOT_URLCONF="pinax.invitations.tests.urls",
2733
SECRET_KEY="notasecret",
34+
TEMPLATES=[
35+
{
36+
"BACKEND": "django.template.backends.django.DjangoTemplates",
37+
"APP_DIRS": True,
38+
"OPTIONS": {
39+
"debug": True,
40+
"context_processors": [
41+
"django.contrib.auth.context_processors.auth",
42+
]
43+
}
44+
},
45+
],
2846
)
2947

3048

setup.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import find_packages, setup
22

3-
VERSION = "6.1.1"
3+
VERSION = "6.1.2"
44
LONG_DESCRIPTION = """
55
.. image:: http://pinaxproject.com/pinax-design/patches/pinax-invitations.svg
66
:target: https://pypi.python.org/pypi/pinax-invitations/
@@ -61,14 +61,6 @@
6161
package_data={
6262
"invitations": []
6363
},
64-
install_requires=[
65-
"django>=1.11",
66-
"django-appconf>=1.0.1",
67-
"django-user-accounts>=2.0.3",
68-
],
69-
test_suite="runtests.runtests",
70-
tests_require=[
71-
],
7264
classifiers=[
7365
"Development Status :: 5 - Production/Stable",
7466
"Environment :: Web Environment",
@@ -87,5 +79,15 @@
8779
'Programming Language :: Python :: 3.6',
8880
"Topic :: Software Development :: Libraries :: Python Modules",
8981
],
82+
install_requires=[
83+
"django>=1.11",
84+
"django-appconf>=1.0.1",
85+
"django-user-accounts>=2.0.3",
86+
],
87+
test_suite="runtests.runtests",
88+
tests_require=[
89+
"django-test-plus",
90+
"pinax-templates>=1.0.2",
91+
],
9092
zip_safe=False,
9193
)

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ inline-quotes = double
88
[isort]
99
multi_line_output=3
1010
known_django=django
11-
known_third_party=account,appconf,pinax
11+
known_third_party=account,appconf,pinax,test_plus
1212
sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
1313
include_trailing_comma=True
1414
skip_glob=**/*/migrations/*

0 commit comments

Comments
 (0)