Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Graves committed Oct 27, 2015
1 parent bb51371 commit 75cbf68
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
2 changes: 2 additions & 0 deletions magma/app.py
Expand Up @@ -2,7 +2,9 @@
from __future__ import absolute_import

import os

from flask import Flask

from magma.home import home_page


Expand Down
21 changes: 11 additions & 10 deletions magma/home/__init__.py
@@ -1,21 +1,22 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import tempfile
import shutil

import os
from zipfile import BadZipfile
import shutil
import tempfile
from contextlib import closing
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from zipfile import BadZipfile

from flask import (Blueprint, flash, request, render_template, make_response,
session,)
from flask import (Blueprint, flash, make_response, render_template, request,)
from werkzeug import secure_filename

from magma.upload import process, datasource
from magma import UnsupportedFormat
from magma.upload import datasource, process

try:
from StringIO import StringIO
except ImportError:
from io import StringIO


home_page = Blueprint('home_page', __name__)
Expand Down
5 changes: 3 additions & 2 deletions magma/upload.py
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from functools import reduce

import glob
import os
from functools import reduce
from zipfile import ZipFile

from osgeo import ogr, gdal
from lxml import etree
from osgeo import gdal, ogr

from magma import UnsupportedFormat

Expand Down
1 change: 0 additions & 1 deletion magma/wsgi.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from magma.app import create_app


application = create_app()
1 change: 1 addition & 0 deletions tests/conftest.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import os

import pytest
Expand Down
10 changes: 6 additions & 4 deletions tests/test_upload.py
@@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from contextlib import closing

import pytest

from magma.upload import FGDC, GeoTIFF, Shapefile

try:
from StringIO import StringIO
except ImportError:
from io import StringIO

import pytest

from magma.upload import Shapefile, FGDC, GeoTIFF


@pytest.yield_fixture
def shp(shapefile):
Expand Down
8 changes: 5 additions & 3 deletions tests/test_views.py
@@ -1,34 +1,36 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import pytest
from webtest import Upload

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 'A datafile is required to proceed' in res


def test_submit_with_invalid_shapefile(testapp):
form = testapp.get('/').form
form['data'] = Upload('tests/fixtures/fgdc.xml')
Expand Down

0 comments on commit 75cbf68

Please sign in to comment.