Пример #1
0
def test_validate_domain_format_with_invalid_domain(domain, dummy_request):
    dummy_request.params = dummy_request.POST = MultiDict({
        'csrf_token': dummy_request.session.get_csrf_token(),
        'domain': domain,
        'application-name': 'Test Site',
    })
    form = build_new_application_site_form(dummy_request)
    assert not form.validate()
    assert form.domain.errors
Пример #2
0
def test_validate_slug_format_with_invalid_slug(slug, dummy_request):
    dummy_request.params = dummy_request.POST = MultiDict({
        'csrf_token': dummy_request.session.get_csrf_token(),
        'slug': slug,
        'domain': 'example.org',
        'application-name': 'New site',
    })
    form = build_new_application_site_form(dummy_request)
    assert not form.validate()
    assert form.slug.errors
Пример #3
0
def test_username_validations_with_valid_inputs(username, dummy_request):
    dummy_request.params = dummy_request.POST = MultiDict({
        'csrf_token': dummy_request.session.get_csrf_token(),
        'username': username,
        'email': '*****@*****.**',
        'password': '******',
    })
    form = build_signup_form(dummy_request)
    assert form.validate()
    assert not form.errors
Пример #4
0
def test_namespace_validations_with_invalid_inputs(namespace, dummy_request):
    project = Project(namespace=namespace)

    dummy_request.params = dummy_request.POST = MultiDict({
        'csrf_token':
        dummy_request.session.get_csrf_token(),
        'name':
        'project-name',
        'namespace':
        namespace,
    })
    form = build_project_form(dummy_request, project)
    assert not form.validate()
Пример #5
0
def test_path_validations_with_invalid_path_inputs(path, scope, progress_state,
                                                   dummy_request):
    article = Article(path=path)

    dummy_request.params = dummy_request.POST = MultiDict({
        'csrf_token':
        dummy_request.session.get_csrf_token(),
        'title':
        'Title',
        'path':
        path,
        'scope':
        scope,
        'progress_state':
        progress_state['value'],
    })
    form = build_article_settings_form(dummy_request, article)
    assert not form.validate()
    assert form.path.errors
Пример #6
0
def test_validate_slug_format_with_valid_slug(slug, dummy_request):
    dummy_request.params = dummy_request.POST = MultiDict({
        'csrf_token':
        dummy_request.session.get_csrf_token(),
        'slug':
        slug,
        'domain':
        None,
        'publication-name':
        'New site',
        'publication-copyright':
        'copyright',
        'publication-classification':
        list(Classification.roots)[0].notation,
        'publication-license':
        next(License.as_choices)[0],
    })
    form = build_new_publication_site_form(dummy_request)
    assert form.validate()
    assert not form.slug.errors