def test_validate_GGNRA(self): ''' Test starting a new data set, and uploading segments. ''' response = self.app.post('/check-dataset', follow_redirects=True) self.assertEqual(response.status_code, 200) datastore = make_datastore(self.config['DATASTORE']) # Ensure there is exactly one file and that it's called ".valid" (filename, ) = datastore.filelist('') self.assertTrue(filename.endswith('/.valid')) # # Check for a file upload field in the home page form. # soup = BeautifulSoup(response.data) form = soup.find('input', attrs=dict(type='file')).find_parent('form') self.assertTrue(form['action'].startswith('/checks')) self.assertTrue(form['action'].endswith('/upload')) self.assertTrue('multipart/form-data' in form['enctype']) self.assertTrue(form.find_all('input', attrs=dict(type='file'))) # Upload a zipped shapefile file = open(os.path.join(self.tmp, 'working-dir', 'open-trails-GGNRA.zip')) uploaded = self.app.post(form['action'], data={"file" : file}, follow_redirects=True) self.assertTrue('Notes' in uploaded.data) # Check for some error notes soup = BeautifulSoup(uploaded.data) self.assertTrue(soup.find(text='Optional trailheads field "area_id" is missing.')) self.assertTrue(soup.find(text='Required stewards field "license" is missing.')) self.assertTrue(soup.find(text='Could not find optional file areas.geojson.'))
def test_validate_GGNRA(self): """ Test starting a new data set, and uploading segments. """ response = self.app.post("/check-dataset", follow_redirects=True) self.assertEqual(response.status_code, 200) datastore = make_datastore(self.config["DATASTORE"]) # Ensure there is exactly one file and that it's called ".valid" (filename,) = datastore.filelist("") self.assertTrue(filename.endswith("/.valid")) # # Check for a file upload field in the home page form. # soup = BeautifulSoup(response.data) form = soup.find("input", attrs=dict(type="file")).find_parent("form") self.assertTrue(form["action"].startswith("/checks")) self.assertTrue(form["action"].endswith("/upload")) self.assertTrue("multipart/form-data" in form["enctype"]) self.assertTrue(form.find_all("input", attrs=dict(type="file"))) # Upload a zipped shapefile file = open(os.path.join(self.tmp, "working-dir", "open-trails-GGNRA.zip")) uploaded = self.app.post(form["action"], data={"file": file}, follow_redirects=True) self.assertTrue("Notes" in uploaded.data) # Check for some error notes soup = BeautifulSoup(uploaded.data) self.assertTrue(soup.find(text='Optional trailheads field "area_id" is missing.')) self.assertTrue(soup.find(text='Required stewards field "license" is missing.')) self.assertTrue(soup.find(text="Could not find optional file areas.geojson."))
def test_validate_GGNRA(self): ''' Test starting a new data set, and uploading segments. ''' response = self.app.post('/check-dataset', follow_redirects=True) self.assertEqual(response.status_code, 200) datastore = make_datastore(self.config['DATASTORE']) # Ensure there is exactly one file and that it's called ".valid" (filename, ) = datastore.filelist('') self.assertTrue(filename.endswith('/.valid')) # # Check for a file upload field in the home page form. # soup = BeautifulSoup(response.data) form = soup.find('input', attrs=dict(type='file')).find_parent('form') self.assertTrue(form['action'].startswith('/checks')) self.assertTrue(form['action'].endswith('/upload')) self.assertTrue('multipart/form-data' in form['enctype']) self.assertTrue(form.find_all('input', attrs=dict(type='file'))) # Upload a zipped shapefile file = open( os.path.join(self.tmp, 'working-dir', 'open-trails-GGNRA.zip')) uploaded = self.app.post(form['action'], data={"file": file}, follow_redirects=True) self.assertTrue('Notes' in uploaded.data) # Check for some error notes soup = BeautifulSoup(uploaded.data) self.assertTrue( soup.find(text='Optional trailheads field "area_id" is missing.')) self.assertTrue( soup.find(text='Required stewards field "license" is missing.')) self.assertTrue( soup.find(text='Could not find optional file areas.geojson.'))
def test_convert_Portland(self): ''' Test starting a new data set, and uploading segments. ''' started = self.app.post('/new-dataset', follow_redirects=True) self.assertEqual(started.status_code, 200) datastore = make_datastore(self.config['DATASTORE']) # Ensure there is exactly one file and that it's called ".valid" (filename, ) = datastore.filelist('') self.assertTrue(filename.endswith('/.valid')) # # Check for a file upload field in the home page form. # soup = BeautifulSoup(started.data) form = soup.find('input', attrs=dict(type='file')).find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/upload')) self.assertTrue('multipart/form-data' in form['enctype']) self.assertTrue(form.find_all('input', attrs=dict(type='file'))) # Upload a zipped shapefile file = open( os.path.join(self.tmp, 'working-dir', 'lake-man-Portland.zip')) uploaded1 = self.app.post(form['action'], data={"file": file}, follow_redirects=True) self.assertTrue('714115' in uploaded1.data) soup = BeautifulSoup(uploaded1.data) form = soup.find('button').find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/transform-segments')) # Do the transforming transformed1 = self.app.post(form['action'], follow_redirects=True) self.assertTrue('714115' in transformed1.data) soup = BeautifulSoup(transformed1.data) form = soup.find('button').find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/name-trails')) # Ask to name the trails named = self.app.post(form['action'], follow_redirects=True) soup = BeautifulSoup(named.data) form = soup.find('input', attrs=dict(name='name')).find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/create-steward')) # Submit stewards information args = dict(name='Winterfell', url='http://codeforamerica.org/governments/winterfell/') stewarded = self.app.post(form['action'], data=args, follow_redirects=True) # # Check for a file upload field in the next page form. # soup = BeautifulSoup(stewarded.data) form = soup.find('input', attrs=dict(type='file')).find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/upload-trailheads')) self.assertTrue('multipart/form-data' in form['enctype']) self.assertTrue(form.find_all('input', attrs=dict(type='file'))) # Upload a zipped shapefile file = open( os.path.join(self.tmp, 'working-dir', 'lake-points-Ohio.zip')) uploaded2 = self.app.post(form['action'], data={"file": file}, follow_redirects=True) self.assertTrue('Rockside' in uploaded2.data) soup = BeautifulSoup(uploaded2.data) form = soup.find('button').find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/transform-trailheads')) # Do the transforming transformed2 = self.app.post(form['action'], follow_redirects=True) self.assertTrue('Rockside' in transformed2.data) soup = BeautifulSoup(transformed2.data) link = soup.find('a', attrs=dict(href=re.compile(r'.+\.zip$'))) zipfile = self.app.get(link['href']) zipfile = ZipFile(StringIO(zipfile.data)) self.assertTrue('trail_segments.geojson' in zipfile.namelist()) self.assertTrue('trailheads.geojson' in zipfile.namelist()) self.assertTrue('named_trails.csv' in zipfile.namelist()) self.assertTrue('stewards.csv' in zipfile.namelist())
def test_convert_Portland(self): ''' Test starting a new data set, and uploading segments. ''' started = self.app.post('/new-dataset', follow_redirects=True) self.assertEqual(started.status_code, 200) datastore = make_datastore(self.config['DATASTORE']) # Ensure there is exactly one file and that it's called ".valid" (filename, ) = datastore.filelist('') self.assertTrue(filename.endswith('/.valid')) # # Check for a file upload field in the home page form. # soup = BeautifulSoup(started.data) form = soup.find('input', attrs=dict(type='file')).find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/upload')) self.assertTrue('multipart/form-data' in form['enctype']) self.assertTrue(form.find_all('input', attrs=dict(type='file'))) # Upload a zipped shapefile file = open(os.path.join(self.tmp, 'working-dir', 'lake-man-Portland.zip')) uploaded1 = self.app.post(form['action'], data={"file" : file}, follow_redirects=True) self.assertTrue('714115' in uploaded1.data) soup = BeautifulSoup(uploaded1.data) form = soup.find('button').find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/transform-segments')) # Do the transforming transformed1 = self.app.post(form['action'], follow_redirects=True) self.assertTrue('714115' in transformed1.data) soup = BeautifulSoup(transformed1.data) form = soup.find('button').find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/name-trails')) # Ask to name the trails named = self.app.post(form['action'], follow_redirects=True) soup = BeautifulSoup(named.data) form = soup.find('input', attrs=dict(name='name')).find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/create-steward')) # Submit stewards information args = dict(name='Winterfell', url='http://codeforamerica.org/governments/winterfell/') stewarded = self.app.post(form['action'], data=args, follow_redirects=True) # # Check for a file upload field in the next page form. # soup = BeautifulSoup(stewarded.data) form = soup.find('input', attrs=dict(type='file')).find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/upload-trailheads')) self.assertTrue('multipart/form-data' in form['enctype']) self.assertTrue(form.find_all('input', attrs=dict(type='file'))) # Upload a zipped shapefile file = open(os.path.join(self.tmp, 'working-dir', 'lake-points-Ohio.zip')) uploaded2 = self.app.post(form['action'], data={"file" : file}, follow_redirects=True) self.assertTrue('Rockside' in uploaded2.data) soup = BeautifulSoup(uploaded2.data) form = soup.find('button').find_parent('form') self.assertTrue(form['action'].startswith('/datasets')) self.assertTrue(form['action'].endswith('/transform-trailheads')) # Do the transforming transformed2 = self.app.post(form['action'], follow_redirects=True) self.assertTrue('Rockside' in transformed2.data) soup = BeautifulSoup(transformed2.data) link = soup.find('a', attrs=dict(href=re.compile(r'.+\.zip$'))) zipfile = self.app.get(link['href']) zipfile = ZipFile(StringIO(zipfile.data)) self.assertTrue('trail_segments.geojson' in zipfile.namelist()) self.assertTrue('trailheads.geojson' in zipfile.namelist()) self.assertTrue('named_trails.csv' in zipfile.namelist()) self.assertTrue('stewards.csv' in zipfile.namelist())
def test_convert_Portland(self): """ Test starting a new data set, and uploading segments. """ response = self.app.post("/new-dataset", follow_redirects=True) self.assertEqual(response.status_code, 200) datastore = make_datastore(self.config["DATASTORE"]) # Ensure there is exactly one file and that it's called ".valid" (filename,) = datastore.filelist("") self.assertTrue(filename.endswith("/.valid")) # # Check for a file upload field in the home page form. # soup = BeautifulSoup(response.data) form = soup.find("input", attrs=dict(type="file")).find_parent("form") self.assertTrue(form["action"].startswith("/datasets")) self.assertTrue(form["action"].endswith("/upload")) self.assertTrue("multipart/form-data" in form["enctype"]) self.assertTrue(form.find_all("input", attrs=dict(type="file"))) # Upload a zipped shapefile file = open(os.path.join(self.tmp, "working-dir", "lake-man-Portland.zip")) uploaded = self.app.post(form["action"], data={"file": file}, follow_redirects=True) self.assertTrue("714115" in uploaded.data) soup = BeautifulSoup(uploaded.data) form = soup.find("button").find_parent("form") self.assertTrue(form["action"].startswith("/datasets")) self.assertTrue(form["action"].endswith("/transform-segments")) # Do the transforming transformed = self.app.post(form["action"], follow_redirects=True) self.assertTrue("714115" in transformed.data) soup = BeautifulSoup(transformed.data) form = soup.find("button").find_parent("form") self.assertTrue(form["action"].startswith("/datasets")) self.assertTrue(form["action"].endswith("/name-trails")) # Ask to name the trails named = self.app.post(form["action"], follow_redirects=True) soup = BeautifulSoup(named.data) form = soup.find("input", attrs=dict(name="name")).find_parent("form") self.assertTrue(form["action"].startswith("/datasets")) self.assertTrue(form["action"].endswith("/create-steward")) # Submit stewards information args = dict(name="Winterfell", url="http://codeforamerica.org/governments/winterfell/") stewarded = self.app.post(form["action"], data=args, follow_redirects=True) soup = BeautifulSoup(stewarded.data) link = soup.find("a", attrs=dict(href=re.compile(r".+\.zip$"))) zipfile = self.app.get(link["href"]) zipfile = ZipFile(StringIO(zipfile.data)) self.assertTrue("trail_segments.geojson" in zipfile.namelist()) self.assertTrue("named_trails.csv" in zipfile.namelist()) self.assertTrue("stewards.csv" in zipfile.namelist())