This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from MITLibraries/2_form_validation
Validate form inputs
- Loading branch information
Showing
4 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
|
||
import pytest | ||
|
||
from webtest import TestApp, Upload | ||
from magma.app import create_app | ||
|
||
def test_can_load_index(testapp): | ||
r = testapp.get('/') | ||
assert r.status_code == 200 | ||
assert 'form' in r | ||
|
||
def test_submit_valid_form(testapp): | ||
form = testapp.get('/').form | ||
form['data'] = Upload('tests/fixtures/SDE_DATA_BD_A8GNS_2003.zip') | ||
form['metadata'] = Upload('tests/fixtures/fgdc.xml') | ||
res = form.submit() | ||
assert res.content_type == 'text/xml' | ||
|
||
def test_submit_with_shapefile_without_metadata(testapp): | ||
form = testapp.get('/').form | ||
form['data'] = Upload('tests/fixtures/SDE_DATA_BD_A8GNS_2003.zip') | ||
res = form.submit() | ||
assert res.content_type == 'text/xml' | ||
|
||
def test_submit_without_shapefile(testapp): | ||
form = testapp.get('/').form | ||
res = form.submit() | ||
assert 'The shapefile is required to proceed' in res | ||
|
||
def test_submit_with_invalid_shapefile(testapp): | ||
form = testapp.get('/').form | ||
form['data'] = Upload('tests/fixtures/fgdc.xml') | ||
res = form.submit() | ||
assert 'File is not a zip file' in res |