Skip to content

Commit

Permalink
remove form fiels in ProfileForm and all tests not required
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-barluzzi committed Jul 24, 2017
1 parent 04b8331 commit d36378d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
12 changes: 0 additions & 12 deletions cadasta/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ def save(self, *args, **kwargs):

class ProfileForm(SanitizeFieldsForm, forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
language = forms.ChoiceField(
choices=settings.LANGUAGES,
error_messages={
'invalid_choice': _('Language invalid or not available')
}
)
measurement = forms.ChoiceField(
choices=settings.MEASUREMENTS,
error_messages={
'invalid_choice': _('Measurement system invalid or not available')
}
)

class Meta:
model = User
Expand Down
48 changes: 0 additions & 48 deletions cadasta/accounts/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,6 @@ def test_signup_with_restricted_username(self):
in form.errors.get('username'))
assert User.objects.count() == 0

def test_signup_with_invalid_language(self):
data = {
'username': 'imagine71',
'email': '[email protected]',
'password': 'iloveyoko79!',
'full_name': 'John Lennon',
'language': 'invalid',
}
form = forms.RegisterForm(data)
assert form.is_valid() is False
assert User.objects.count() == 0
assert ('Select a valid choice. invalid is not one of the '
'available choices.' in form.errors.get('language'))

def test_sanitize(self):
data = {
'username': '😛😛😛😛',
Expand Down Expand Up @@ -430,40 +416,6 @@ def test_update_email_with_incorrect_password(self):
assert ("Please provide the correct password for your account." in
form.errors['password'])

def test_update_with_invalid_language(self):
user = UserFactory.create(email='[email protected]',
password='imagine71',
language='en')
data = {
'username': 'imagine71',
'email': '[email protected]',
'full_name': 'John Lennon',
'password': 'stg-pepper',
'language': 'invalid'
}
form = forms.ProfileForm(data, instance=user)
assert form.is_valid() is False
assert user.language == 'en'
assert ('Language invalid or not available'
in form.errors.get('language'))

def test_update_user_with_invalid_measurement(self):
user = UserFactory.create(email='[email protected]',
password='imagine71',
measurement='metric')
data = {
'username': 'imagine71',
'email': '[email protected]',
'full_name': 'John Lennon',
'password': 'stg-pepper',
'measurement': 'invalid'
}
form = forms.ProfileForm(data, instance=user)
assert form.is_valid() is False
assert user.measurement == 'metric'
assert ('Measurement system invalid or not available'
in form.errors['measurement'])

def test_sanitize(self):
user = UserFactory.create(email='[email protected]',
password='imagine71')
Expand Down

0 comments on commit d36378d

Please sign in to comment.