示例#1
0
def test_sign_up_form_clear():
    form = SignUpForm()
    form.cleaned_data = {
        'password': '******',
        'password2': 'password',
        'phone': ''.join(i for i in FAKE.phone_number() if i.isdigit())[:10]
    }
    form.clean()
    form.save()
示例#2
0
def test_sign_up_form_not_clear():
    form = SignUpForm()
    form.errors['fake_error'] = 'fake'
    form.cleaned_data = {
        'password': '******',
        'password2': 'password',
        'phone': ''.join(i for i in FAKE.phone_number() if i.isdigit())[:10]
    }
    form.clean()
    form.errors.pop('fake_error')
示例#3
0
def test_sign_up_form_to_short_phone():
    form = SignUpForm()
    form.cleaned_data = {
        'password': '******',
        'password2': 'password',
        'phone': '2'
    }
    try:
        form.clean()
    except ValidationError:
        pass
    else:
        assert 2 == 1
示例#4
0
def test_sign_up_form_wrong_phone():
    form = SignUpForm()
    form.cleaned_data = {
        'password': '******',
        'password2': 'password',
        'phone': FAKE.phone_number()
    }
    try:
        form.clean()
    except ValidationError:
        pass
    else:
        assert 2 == 1
示例#5
0
def test_sign_up_form_wrong_password2():
    form = SignUpForm()
    form.cleaned_data = {
        'password': '******',
        'password2': 'password2',
        'phone': ''.join(i for i in FAKE.phone_number() if i.isdigit())[:10]
    }
    try:
        form.clean()
    except ValidationError:
        pass
    else:
        assert 2 == 1