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

Commit

Permalink
flake8 updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
JivanAmara committed Nov 28, 2016
1 parent fde4d18 commit 188fe33
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
8 changes: 5 additions & 3 deletions osgeo_importer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ def import_all_layers(self, request, api_name=None, resource_name=None, pk=None)
def prepend_urls(self):
pu = super(UploadedDataResource, self).prepend_urls()
pu.extend([
url(r'^(?P<resource_name>{0})/(?P<pk>\w[\w/-]*)/import_all_layers{1}$'\
.format(self._meta.resource_name, trailing_slash()),
url(
r'^(?P<resource_name>{0})/(?P<pk>\w[\w/-]*)/import_all_layers{1}$'
.format(self._meta.resource_name, trailing_slash()),
self.wrap_view('import_all_layers'),
name='import_all_data'
),
)
])
return pu


class MultipartResource(object):

def deserialize(self, request, data, format=None):
Expand Down
1 change: 0 additions & 1 deletion osgeo_importer/handlers/geonode/publish_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def handle(self, layer, layer_config, *args, **kwargs):
logger.warn('User "{}" not found using AnonymousUser.'.format(layer_config['layer_owner']))
owner = User.objects.get(username='AnonymousUser')


# Populate arguments to create a new Layer
if layer_config.get('raster'):
layer_name = os.path.splitext(os.path.basename(layer))[0]
Expand Down
9 changes: 1 addition & 8 deletions osgeo_importer/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django import db


def works_with_geoserver(wrapped_func):
""" A decorator for test methods with functionality that should work with or without geoserver
Expand All @@ -25,14 +25,7 @@ def wrapper(self, *args, **kwargs):
if self.catalog.get_workspace(workspace_name) is None:
self.catalog.create_workspace(workspace_name, 'http://www.geonode.org/')

workspace = self.catalog.get_workspace(workspace_name)

# self.postgis = db.connections['datastore']
# self.postgis_settings = self.postgis.settings_dict
# self.datastore = self.catalog.create_datastore(self.postgis, workspace)

ret = wrapped_func(self, *args, **kwargs)
# self.catalog.delete(self.datastore, recurse=True)

return ret
else:
Expand Down
9 changes: 5 additions & 4 deletions osgeo_importer/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import os
import shutil

from django.conf import settings
from django.contrib.auth import get_user_model
from django.test import TestCase

from geonode.layers.models import Layer
from osgeo_importer.models import UploadedData
from osgeo_importer.tests.test_settings import _TEST_FILES_DIR
from osgeo_importer.utils import ImportHelper, import_all_layers
from osgeo_importer.utils import ImportHelper
from osgeo_importer.tests.helpers import works_with_geoserver


Expand Down Expand Up @@ -51,7 +50,8 @@ def test_import_all_layers(self):

ud = UploadedData.objects.get(name=test_filename)
n_uploaded_layers = ud.uploadlayer_set.count()
self.assertEqual(n_uploaded_layers, expected_layer_count,
self.assertEqual(
n_uploaded_layers, expected_layer_count,
'Expected {} uploaded layers from this file, found {}'.format(expected_layer_count, n_uploaded_layers)
)

Expand All @@ -64,6 +64,7 @@ def test_import_all_layers(self):
self.assertEqual(result['layer_count'], expected_layer_count)

n_imported_layers = Layer.objects.count()
self.assertEqual(n_imported_layers, expected_layer_count,
self.assertEqual(
n_imported_layers, expected_layer_count,
'Expected {} imported layers from this file, found {}'.format(expected_layer_count, n_imported_layers)
)
7 changes: 4 additions & 3 deletions osgeo_importer/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from django.contrib.auth import get_user_model
from django.test import TestCase
import mock

from geonode.layers.models import Layer
from osgeo_importer.models import UploadedData
Expand Down Expand Up @@ -45,13 +44,15 @@ def test_import_all_layers(self):

ud = UploadedData.objects.get(name=test_filename)
n_uploaded_layers = ud.uploadlayer_set.count()
self.assertEqual(n_uploaded_layers, expected_layer_count,
self.assertEqual(
n_uploaded_layers, expected_layer_count,
'Expected {} uploaded layers from this file, found {}'.format(expected_layer_count, n_uploaded_layers)
)

import_all_layers(ud, owner=test_user)

n_imported_layers = Layer.objects.count()
self.assertEqual(n_imported_layers, expected_layer_count,
self.assertEqual(
n_imported_layers, expected_layer_count,
'Expected {} imported layers from this file, found {}'.format(expected_layer_count, n_imported_layers)
)
3 changes: 2 additions & 1 deletion osgeo_importer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def decode(s, encodings=('ascii', 'utf8', 'latin1')):
pass
return s.decode('ascii', 'ignore')


class ImportHelper(object):
"""
Import Helpers
Expand Down Expand Up @@ -475,5 +476,5 @@ def import_all_layers(uploaded_data, owner=None):
uploaded_layer.save()

# Wait for all of the results to complete before returning
[ ir.wait() for ir in import_results ]
[ir.wait() for ir in import_results]
return len(import_results)
2 changes: 1 addition & 1 deletion osgeo_importer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class FileAddView(ImportHelper, FormView, JSONResponseMixin):

def form_valid(self, form):
upload = self.upload(form.cleaned_data['file'], self.request.user)
files = [ f for f in form.cleaned_data['file'] ]
files = [f for f in form.cleaned_data['file']]
self.configure_upload(upload, files)

if self.json:
Expand Down

0 comments on commit 188fe33

Please sign in to comment.