Merge branch 'develop' into feature/hosting_permission
This commit is contained in:
commit
3e6502133e
24 changed files with 638 additions and 61 deletions
|
|
@ -48,7 +48,6 @@ class SetPasswordForm(forms.Form):
|
|||
return password2
|
||||
|
||||
|
||||
|
||||
class BillingAddressForm(forms.ModelForm):
|
||||
token = forms.CharField(widget=forms.HiddenInput())
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ class StripeUtils(object):
|
|||
)
|
||||
return customer
|
||||
|
||||
|
||||
@handleStripeError
|
||||
def make_charge(self, amount=None, customer=None):
|
||||
amount = int(amount * 100) # stripe amount unit, in cents
|
||||
|
|
|
|||
|
|
@ -1,5 +1,51 @@
|
|||
from django.test import TestCase
|
||||
from .forms import ContactUsForm, BillingAddressForm
|
||||
from .forms import ContactUsForm, BillingAddressForm, PasswordResetRequestForm,\
|
||||
SetPasswordForm
|
||||
|
||||
from model_mommy import mommy
|
||||
|
||||
|
||||
class PasswordResetRequestFormTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.user = mommy.make('CustomUser')
|
||||
self.completed_data = {
|
||||
'email': self.user.email,
|
||||
}
|
||||
|
||||
self.incorrect_data = {
|
||||
'email': 'test',
|
||||
}
|
||||
|
||||
def test_valid_form(self):
|
||||
form = PasswordResetRequestForm(data=self.completed_data)
|
||||
self.assertTrue(form.is_valid())
|
||||
|
||||
def test_invalid_form(self):
|
||||
form = PasswordResetRequestForm(data=self.incorrect_data)
|
||||
self.assertFalse(form.is_valid())
|
||||
|
||||
|
||||
class SetPasswordFormTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# self.user = mommy.make('CustomUser')
|
||||
self.completed_data = {
|
||||
'new_password1': 'new_password',
|
||||
'new_password2': 'new_password',
|
||||
}
|
||||
|
||||
self.incorrect_data = {
|
||||
'email': 'test',
|
||||
}
|
||||
|
||||
def test_valid_form(self):
|
||||
form = SetPasswordForm(data=self.completed_data)
|
||||
self.assertTrue(form.is_valid())
|
||||
|
||||
def test_invalid_form(self):
|
||||
form = SetPasswordForm(data=self.incorrect_data)
|
||||
self.assertFalse(form.is_valid())
|
||||
|
||||
|
||||
class ContactUsFormTest(TestCase):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from django.test import TestCase
|
||||
from django.test import Client
|
||||
from django.http.request import HttpRequest
|
||||
|
||||
from model_mommy import mommy
|
||||
|
||||
|
||||
|
|
@ -28,6 +30,11 @@ class BaseTestCase(TestCase):
|
|||
self.customer_client = self.get_client(self.customer)
|
||||
self.another_customer_client = self.get_client(self.another_customer)
|
||||
|
||||
# Request Object
|
||||
self.request = HttpRequest()
|
||||
self.request.META['SERVER_NAME'] = 'ungleich.com'
|
||||
self.request.META['SERVER_PORT'] = '80'
|
||||
|
||||
def get_client(self, user):
|
||||
"""
|
||||
Authenticate a user and return the client
|
||||
|
|
@ -64,3 +71,14 @@ class BaseTestCase(TestCase):
|
|||
}]
|
||||
}
|
||||
}
|
||||
|
||||
def setup_view(self, view, *args, **kwargs):
|
||||
"""Mimic as_view() returned callable, but returns view instance.
|
||||
|
||||
args and kwargs are the same you would pass to ``reverse()``
|
||||
|
||||
"""
|
||||
view.request = self.request
|
||||
view.args = args
|
||||
view.kwargs = kwargs
|
||||
return view
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue