Private
Public Access
1
0
This commit is contained in:
2025-10-30 15:38:40 +01:00
parent 12eb7cb978
commit 4ce06f75a9
5 changed files with 43 additions and 9 deletions

View File

@@ -5,7 +5,8 @@ from __future__ import unicode_literals
#from __future__ import print_function
from .statements import *
from django_recaptcha.client import RecaptchaResponse
from django_recaptcha.fields import ReCaptchaField
nu = datetime.datetime.now()
#@pytest.mark.django_db
@@ -22,7 +23,11 @@ class NewUserRegistrationTest(TestCase):
pass
@patch('rowers.dataprep.workout_summary_to_df',side_effect=mock_workout_summaries)
def test_newuser(self,mock_workout_summaries):
@patch("django_recaptcha.fields.client.submit")
def test_newuser(self,mock_submit, mock_workout_summaries):
mock_response = RecaptchaResponse(is_valid=True, extra_data={'score': 0.95})
mock_submit.return_value = mock_response
form_data = {
'first_name':'Jan',
'last_name':'Roeiert',
@@ -30,16 +35,21 @@ class NewUserRegistrationTest(TestCase):
'username':'janderoeiert',
'password1':'Aapindewei2',
'password2':'Aapindewei2',
'url': '',
'hp_field': '',
'tos':True,
'weightcategory':'hwt',
'adaptiveclass': 'None',
'sex':'male',
'captcha': 'PASSED',
'g-recaptcha-response': 'PASSED',
'next':'/rowers/list-workouts',
'birthdate':datetime.datetime(year=1970,month=4,day=2)
}
form = RegistrationFormSex(form_data)
if not form.is_valid():
print(form.errors)
self.assertTrue(form.is_valid())
response = self.c.post('/rowers/register/', form_data, follow=True)
@@ -118,7 +128,7 @@ class NewUserRegistrationTest(TestCase):
'password1':'aapindewei2',
'password2':'aapindewei2',
'tos':True,
'url': '',
'hp_field': '',
'weightcategory':'hwt',
'adaptiveclass': 'None',
'sex':'male',
@@ -126,6 +136,7 @@ class NewUserRegistrationTest(TestCase):
'birthdate':datetime.datetime(year=1970,month=4,day=2)
}
form = RegistrationFormSex(form_data)
self.assertFalse(form.is_valid())
@@ -138,7 +149,7 @@ class NewUserRegistrationTest(TestCase):
'username':'janderoeiert',
'password1':'Aapindewei2',
'password2':'Aapindewei2',
'url': 'http://example.com',
'hp_field': 'http://example.com',
'tos':True,
'weightcategory':'hwt',
'adaptiveclass': 'None',

Binary file not shown.