From d36378d62697280cb94adbc8a8ef6bb1f3930390 Mon Sep 17 00:00:00 2001 From: Laura Barluzzi Date: Mon, 24 Jul 2017 09:57:01 -0700 Subject: [PATCH] remove form fiels in ProfileForm and all tests not required --- cadasta/accounts/forms.py | 12 ------- cadasta/accounts/tests/test_forms.py | 48 ---------------------------- 2 files changed, 60 deletions(-) diff --git a/cadasta/accounts/forms.py b/cadasta/accounts/forms.py index 5ef1306a0..c18cd60cf 100644 --- a/cadasta/accounts/forms.py +++ b/cadasta/accounts/forms.py @@ -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 diff --git a/cadasta/accounts/tests/test_forms.py b/cadasta/accounts/tests/test_forms.py index e225bf109..aae239abe 100644 --- a/cadasta/accounts/tests/test_forms.py +++ b/cadasta/accounts/tests/test_forms.py @@ -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': 'john@beatles.uk', - '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': '😛😛😛😛', @@ -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='john@beatles.uk', - password='imagine71', - language='en') - data = { - 'username': 'imagine71', - 'email': 'john2@beatles.uk', - '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='john@beatles.uk', - password='imagine71', - measurement='metric') - data = { - 'username': 'imagine71', - 'email': 'john2@beatles.uk', - '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='john@beatles.uk', password='imagine71')