diff --git a/.gitignore b/.gitignore index d8ad4e1..d716ada 100644 --- a/.gitignore +++ b/.gitignore @@ -93,6 +93,7 @@ sandbox/ # macOS auto-generated files .DS_Store +.idea/ # Apache conf file conf.d/virtual-host.conf diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6724e54 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: python +python: + - "2.7" +install: pip install -r requirements-dev.txt +script: PYTHONPATH=`pwd` py.test --cov=gioland tests +after_success: coveralls +notifications: + email: + recipients: + - purepython@eaudeweb.ro diff --git a/README.rst b/README.rst index 776f842..f0670b5 100644 --- a/README.rst +++ b/README.rst @@ -16,6 +16,15 @@ Code repository: https://github.com/eea/gioland .. _`this issue`: http://taskman.eionet.europa.eu/issues/2 +.. image:: https://travis-ci.org/eea/gioland.svg?branch=master + :target: https://travis-ci.org/eea/gioland + +.. image:: https://coveralls.io/repos/github/eea/gioland/badge.svg?branch=master + :target: https://coveralls.io/github/eea/gioland?branch=master + +.. image:: https://dockerbuildbadges.quelltext.eu/status.svg?organization=eeacms&repository=gioland + :target: https://hub.docker.com/r/eeacms/gioland/builds + Installation (using docker) =========================== diff --git a/gioland/__init__.py b/gioland/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/auth.py b/gioland/auth.py similarity index 97% rename from auth.py rename to gioland/auth.py index 7daefd5..52d9f99 100644 --- a/auth.py +++ b/gioland/auth.py @@ -1,11 +1,12 @@ -import urlparse from functools import wraps + import flask import ldap +import urlparse from eea.usersdb import UsersDB -from utils import cached -from definitions import ALL_ROLES +from gioland.definitions import ALL_ROLES +from gioland.utils import cached auth_views = flask.Blueprint('auth', __name__) @@ -145,7 +146,7 @@ def roles_debug(): @auth_views.route('/logs') @require_admin def view_logs(): - import warehouse + from gioland import warehouse app = flask.current_app warehouse_log_file = app.config['WAREHOUSE_PATH'] / warehouse.LOG_FILE_NAME with warehouse_log_file.open('rb') as log_file: diff --git a/definitions.py b/gioland/definitions.py similarity index 99% rename from definitions.py rename to gioland/definitions.py index 0e4c40e..d3d495e 100644 --- a/definitions.py +++ b/gioland/definitions.py @@ -1,6 +1,6 @@ from collections import OrderedDict -from utils import remove_duplicates_preserve_order +from gioland.utils import remove_duplicates_preserve_order SIMILAR_METADATA = ( 'country', diff --git a/forms.py b/gioland/forms.py similarity index 84% rename from forms.py rename to gioland/forms.py index 86494d8..1e3ea1a 100644 --- a/forms.py +++ b/gioland/forms.py @@ -1,13 +1,15 @@ from datetime import datetime + +from flask import g from wtforms import Form, SelectField from wtforms.validators import DataRequired, ValidationError -from flask import g -from warehouse import get_warehouse -from definitions import COUNTRIES, COUNTRY, COUNTRY_PRODUCTS -from definitions import COUNTRY_LOT_PRODUCTS, DEFAULT_REFERENCE, EXTENTS -from definitions import INITIAL_STAGE, LOT, LOT_PRODUCTS, LOTS, PRODUCTS -from definitions import RESOLUTIONS, REFERENCES, STREAM, STREAM_LOTS -from definitions import STREAM_LOT_PRODUCTS + +from gioland.definitions import COUNTRIES, COUNTRY, COUNTRY_PRODUCTS +from gioland.definitions import COUNTRY_LOT_PRODUCTS, DEFAULT_REFERENCE, EXTENTS +from gioland.definitions import INITIAL_STAGE, LOT, LOT_PRODUCTS, LOTS, PRODUCTS +from gioland.definitions import RESOLUTIONS, REFERENCES, STREAM, STREAM_LOTS +from gioland.definitions import STREAM_LOT_PRODUCTS +from gioland.warehouse import get_warehouse def get_lot_products(lot_id, delivery_type): diff --git a/notification.py b/gioland/notification.py similarity index 94% rename from notification.py rename to gioland/notification.py index 9e1db9f..32bbe2a 100644 --- a/notification.py +++ b/gioland/notification.py @@ -1,13 +1,14 @@ import logging -from xmlrpclib import ServerProxy -import flask + import blinker -from definitions import COUNTRY, COUNTRY_EXCLUDE_METADATA, LOT -from definitions import LOT_EXCLUDE_METADATA, METADATA, RDF_URI -from definitions import STREAM_EXCLUDE_METADATA, UNS_FIELD_DEFS -import auth +import flask from utils import format_datetime +from xmlrpclib import ServerProxy +import gioland.auth as auth +from gioland.definitions import COUNTRY, COUNTRY_EXCLUDE_METADATA, LOT +from gioland.definitions import LOT_EXCLUDE_METADATA, METADATA, RDF_URI +from gioland.definitions import STREAM_EXCLUDE_METADATA, UNS_FIELD_DEFS metadata_rdf_fields = [(field['rdf_uri'], field['name'], dict(field['range'])) for field in UNS_FIELD_DEFS diff --git a/parcel.py b/gioland/parcel.py similarity index 96% rename from parcel.py rename to gioland/parcel.py index 551d8ed..3ce7579 100644 --- a/parcel.py +++ b/gioland/parcel.py @@ -2,37 +2,35 @@ import os import re import tempfile - from cgi import escape -from itertools import groupby from datetime import datetime +from itertools import groupby -import flask import blinker - +import flask from flask.views import MethodView -from werkzeug.utils import secure_filename -from werkzeug.security import safe_join - from path import path +from werkzeug.security import safe_join +from werkzeug.utils import secure_filename -import notification -import auth -from definitions import ALL_STAGES_MAP, ALL_ROLES, CATEGORIES, COUNTRIES -from definitions import COUNTRIES_CC, COUNTRIES_MC, COUNTRY_PRODUCTS, COUNTRY -from definitions import COUNTRY_LOT_PRODUCTS, DOCUMENTS, EDITABLE_METADATA -from definitions import EXTENTS, FULL_LOT_STAGES, FULL_LOT_STAGES_ORDER -from definitions import INITIAL_STAGE, LOT, LOTS, LOT_STAGES, METADATA, PARTIAL -from definitions import PARTIAL_LOT_STAGES, PARTIAL_LOT_STAGES_ORDER -from definitions import PRODUCTS, PRODUCTS_FILTER, PRODUCTS_IDS, REFERENCES -from definitions import REPORT_METADATA, RESOLUTIONS, SIMILAR_METADATA -from definitions import STAGE_ORDER, STAGES, STAGES_FOR_MERGING, STREAM -from definitions import STREAM_LOTS, STREAM_STAGES, STREAM_STAGES_ORDER -from definitions import UNS_FIELD_DEFS -from warehouse import get_warehouse, _current_user -from utils import format_datetime, exclusive_lock, isoformat_to_datetime -from forms import CountryDeliveryForm, LotDeliveryForm, StreamDeliveryForm -from forms import get_lot_products +import gioland.auth as auth +import gioland.notification as notification + +from gioland.definitions import ALL_STAGES_MAP, ALL_ROLES, CATEGORIES, COUNTRIES +from gioland.definitions import COUNTRIES_CC, COUNTRIES_MC, COUNTRY_PRODUCTS, COUNTRY +from gioland.definitions import DOCUMENTS, EDITABLE_METADATA +from gioland.definitions import EXTENTS, FULL_LOT_STAGES, FULL_LOT_STAGES_ORDER +from gioland.definitions import INITIAL_STAGE, LOT, LOTS, LOT_STAGES, METADATA, PARTIAL +from gioland.definitions import PARTIAL_LOT_STAGES, PARTIAL_LOT_STAGES_ORDER +from gioland.definitions import PRODUCTS, PRODUCTS_FILTER, PRODUCTS_IDS, REFERENCES +from gioland.definitions import REPORT_METADATA, RESOLUTIONS, SIMILAR_METADATA +from gioland.definitions import STAGE_ORDER, STAGES, STAGES_FOR_MERGING, STREAM +from gioland.definitions import STREAM_LOTS, STREAM_STAGES, STREAM_STAGES_ORDER +from gioland.definitions import UNS_FIELD_DEFS +from gioland.forms import CountryDeliveryForm, LotDeliveryForm, StreamDeliveryForm +from gioland.forms import get_lot_products +from gioland.utils import format_datetime, exclusive_lock, isoformat_to_datetime +from gioland.warehouse import get_warehouse, _current_user parcel_views = flask.Blueprint('parcel', __name__) diff --git a/utils.py b/gioland/utils.py similarity index 98% rename from utils.py rename to gioland/utils.py index e1efb96..a14111b 100644 --- a/utils.py +++ b/gioland/utils.py @@ -1,13 +1,13 @@ -import time -from functools import wraps import logging +import time from contextlib import contextmanager -from werkzeug.contrib.cache import NullCache, SimpleCache +from functools import wraps + import flask from dateutil import tz, parser +from werkzeug.contrib.cache import NullCache, SimpleCache from zc.lockfile import LockFile, LockError - log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) @@ -41,7 +41,7 @@ def initialize_app(app): def format_datetime(value, format_name='long'): """ Formats a datetime according to the given format. """ - from definitions import DATE_FORMAT + from gioland.definitions import DATE_FORMAT timezone = flask.current_app.config.get("TIME_ZONE") if timezone: from_zone = tz.gettz("UTC") diff --git a/warehouse.py b/gioland/warehouse.py similarity index 97% rename from warehouse.py rename to gioland/warehouse.py index 91cc532..1d4cf6d 100644 --- a/warehouse.py +++ b/gioland/warehouse.py @@ -1,19 +1,18 @@ -import tempfile import hashlib -from datetime import datetime import logging import logging.handlers -from persistent.list import PersistentList -from persistent.mapping import PersistentMapping -from BTrees.OOBTree import OOBTree -from persistent import Persistent +import tempfile +from datetime import datetime + import transaction +from BTrees.OOBTree import OOBTree from path import path +from persistent import Persistent +from persistent.list import PersistentList +from persistent.mapping import PersistentMapping -from definitions import METADATA, STAGES, LOT_STAGES, COUNTRY_EXCLUDE_METADATA, STREAM, STREAM_EXCLUDE_METADATA -from definitions import STAGE_ORDER, LOT_STAGE_ORDER -from definitions import LOT, COUNTRY - +from gioland.definitions import COUNTRY +from gioland.definitions import METADATA, COUNTRY_EXCLUDE_METADATA, STREAM, STREAM_EXCLUDE_METADATA log = logging.getLogger(__name__) @@ -80,7 +79,7 @@ def uploading(self): @property def file_uploading(self): - from parcel import _get_stages_for_parcel + from gioland.parcel import _get_stages_for_parcel DELIVERY_STAGES, _ = _get_stages_for_parcel(self) stage = DELIVERY_STAGES.get(self.metadata.get('stage'), {}) return stage.get('file_uploading', False) @@ -312,7 +311,7 @@ def _cleanup_warehouse(err=None): def initialize_app(app): import flask - import auth + from gioland import auth if 'WAREHOUSE_PATH' not in app.config: return diff --git a/manage.py b/manage.py index 2b8135e..2f63cbc 100755 --- a/manage.py +++ b/manage.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -import os -import logging import code import copy +import logging +import os import flask from flask.ext import script @@ -24,7 +24,7 @@ def register_monitoring_views(app): - import warehouse + from gioland import warehouse @app.route('/ping') def ping(): @@ -37,10 +37,10 @@ def crash(): def create_app(config={}, testing=False): - import auth - import parcel - import warehouse - import utils + from gioland import auth + from gioland import parcel + from gioland import warehouse + from gioland import utils app = flask.Flask(__name__) app.config.update(copy.deepcopy(default_config)) if testing: @@ -154,7 +154,7 @@ def run(): context = {'app': app} if warehouse: - import warehouse + from gioland import warehouse import transaction context['wh'] = warehouse.get_warehouse() context['transaction'] = transaction @@ -169,7 +169,7 @@ def run(): @manager.command def migrate_prev_parcel_to_list(): - from warehouse import get_warehouse + from gioland.warehouse import get_warehouse wh = get_warehouse() parcels = wh.get_all_parcels() @@ -183,7 +183,7 @@ def migrate_prev_parcel_to_list(): @manager.command def fsck(): - from warehouse import get_warehouse, checksum + from gioland.warehouse import get_warehouse, checksum wh = get_warehouse() parcels = wh.get_all_parcels() @@ -198,7 +198,7 @@ def fsck(): @manager.command def update_tree(): - from warehouse import get_warehouse + from gioland.warehouse import get_warehouse wh = get_warehouse() parcels = [p for p in wh.get_all_parcels() if not p.uploading] parcels.sort(key=lambda p: p.metadata['upload_time']) diff --git a/requirements-dev.txt b/requirements-dev.txt index cd03922..ece35c8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,10 @@ -r requirements.txt + nose==1.1.2 mock==0.8.0 lxml==2.3.3 Pygments==1.5 docutils==0.9.1 honcho==0.2.0 +pytest-cov==1.8.1 +coveralls==0.5 diff --git a/tests/common.py b/tests/common.py index 1bccd26..1ec25fa 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1,11 +1,13 @@ +import tempfile import unittest from contextlib import contextmanager -import tempfile + import flask from mock import patch from path import path from werkzeug.datastructures import ImmutableDict -from definitions import COUNTRY, LOT + +from gioland.definitions import COUNTRY, LOT def create_mock_app(warehouse_path=None): @@ -37,7 +39,7 @@ def test_logout(): def authorization_patch(): - authorize_patch = patch('auth.authorize') + authorize_patch = patch('gioland.auth.authorize') authorize_patch.start() return authorize_patch @@ -58,8 +60,7 @@ def _record(sender, **extra): def select(container, selector): """ Select elements using CSS """ - import lxml.html - import lxml.cssselect + import lxml.cssselect, lxml.html if isinstance(container, basestring): doc = lxml.html.fromstring(container.decode('utf-8')) else: @@ -112,7 +113,7 @@ def new_parcel(self, delivery_type=COUNTRY, **extra_metadata): else: metadata = dict(self.STREAM_METADATA) url = '/parcel/new/stream' - with patch('auth.authorize'): + with patch('gioland.auth.authorize'): resp = self.client.post(url, data=metadata) self.assertEqual(resp.status_code, 302) parcel_name = resp.location.rsplit('/', 1)[-1] @@ -141,7 +142,7 @@ def close_warehouse(): @property def wh(self): - import warehouse + from gioland import warehouse return warehouse.get_warehouse() def __call__(self, result=None): diff --git a/tests/index_page_test.py b/tests/index_page_test.py index e460a15..77949f2 100644 --- a/tests/index_page_test.py +++ b/tests/index_page_test.py @@ -1,5 +1,6 @@ from common import AppTestCase, authorization_patch, select -from definitions import LOT + +from gioland.definitions import LOT class UploadTest(AppTestCase): diff --git a/tests/notification_test.py b/tests/notification_test.py index 761881e..bcc45e4 100644 --- a/tests/notification_test.py +++ b/tests/notification_test.py @@ -1,20 +1,22 @@ -from datetime import datetime from contextlib import contextmanager -from mock import Mock, patch, call -from dateutil import tz +from datetime import datetime + from common import AppTestCase, record_events, authorization_patch -from definitions import COUNTRY +from dateutil import tz +from mock import Mock, patch, call + +from gioland.definitions import COUNTRY def setUpModule(self): - import notification + from gioland import notification self.notification = notification class NotificationDeliveryTest(AppTestCase): def setUp(self): - import warehouse + from gioland import warehouse self.app.config['BASE_URL'] = 'http://example.com' @@ -41,7 +43,7 @@ def test_notification_calls_uns(self): self.assertEqual(len(events), 1) def test_notification_rdf(self): - from definitions import RDF_URI + from gioland.definitions import RDF_URI zone = 'Asia/Tokyo' self.app.config['TIME_ZONE'] = zone @@ -70,7 +72,7 @@ def test_notification_rdf(self): @contextmanager def record_uns_calls(self): - with patch('notification.get_uns_proxy') as mock_get_uns_proxy: + with patch('gioland.notification.get_uns_proxy') as mock_get_uns_proxy: sendNotification = mock_get_uns_proxy.return_value.sendNotification with self.app.test_request_context(): yield sendNotification.mock_calls @@ -118,7 +120,7 @@ def test_notification_not_triggered_on_new_parcel(self): self.assertEqual(events, []) def test_notification_triggered_once_on_finalize_parcel(self): - from definitions import RDF_URI + from gioland.definitions import RDF_URI resp_1 = self.client.post('/parcel/new/country', data=self.PARCEL_METADATA) self.assertEqual(resp_1.status_code, 302) parcel_name = resp_1.location.rsplit('/', 1)[-1] @@ -134,9 +136,9 @@ def test_notification_triggered_once_on_finalize_parcel(self): " (stage reference: %s)" % parcel_name)) self.assertNotIn(RDF_URI['decision'], event_rdf) - @patch('parcel.authorize_for_parcel', Mock(return_value=True)) + @patch('gioland.parcel.authorize_for_parcel', Mock(return_value=True)) def test_parcel_rejection_triggers_accept_notification(self): - from definitions import RDF_URI + from gioland.definitions import RDF_URI resp_1 = self.client.post('/parcel/new/country', data=self.PARCEL_METADATA) self.assertEqual(resp_1.status_code, 302) parcel1_name = resp_1.location.rsplit('/', 1)[-1] @@ -155,9 +157,9 @@ def test_parcel_rejection_triggers_accept_notification(self): event_rdf = rdfdata(events[0]) self.assertEqual(event_rdf[RDF_URI['decision']], "accepted") - @patch('parcel.authorize_for_parcel', Mock(return_value=True)) + @patch('gioland.parcel.authorize_for_parcel', Mock(return_value=True)) def test_parcel_rejection_triggers_rejection_notification(self): - from definitions import RDF_URI + from gioland.definitions import RDF_URI resp_1 = self.client.post('/parcel/new/country', data=self.PARCEL_METADATA) self.assertEqual(resp_1.status_code, 302) parcel1_name = resp_1.location.rsplit('/', 1)[-1] @@ -184,15 +186,15 @@ def setUp(self): self.channel_id = '1234' self.app.config['UNS_CHANNEL_ID'] = self.channel_id - @patch('notification.get_uns_proxy') + @patch('gioland.notification.get_uns_proxy') def test_subscribe_calls_to_uns(self, mock_proxy): self.client.post('/subscribe') self.assertEqual(mock_proxy.return_value.makeSubscription.mock_calls, [call(self.channel_id, 'somebody', [])]) - @patch('notification.get_uns_proxy') + @patch('gioland.notification.get_uns_proxy') def test_subscribe_with_filters_passes_filters_to_uns(self, mock_proxy): - from definitions import RDF_URI + from gioland.definitions import RDF_URI self.client.post('/subscribe', data={ 'country': 'dk', diff --git a/tests/parcel_test.py b/tests/parcel_test.py index 61cb577..6e6bd7a 100644 --- a/tests/parcel_test.py +++ b/tests/parcel_test.py @@ -1,13 +1,13 @@ +import string from datetime import datetime -from StringIO import StringIO -from mock import patch -import string import flask - -from definitions import COUNTRY, LOT +from StringIO import StringIO from common import AppTestCase, authorization_patch, select -from parcel import _get_stages_for_parcel +from mock import patch +from gioland.parcel import _get_stages_for_parcel + +from gioland.definitions import COUNTRY, LOT class ParcelTest(AppTestCase): @@ -185,7 +185,7 @@ def test_finalize_with_reject_saves_rejected_metadata(self): self.assertTrue(parcel.metadata['rejection']) def test_get_parcels_by_stage(self): - import parcel + from gioland import parcel self.new_parcel(stage='c-int') parcel_name_1 = self.new_parcel(stage='c-fsc') self.client.post('/parcel/%s/finalize' % parcel_name_1, @@ -313,8 +313,8 @@ class ParcelHistoryTest(AppTestCase): CREATE_WAREHOUSE = True def setUp(self): - datetime_patch = patch('forms.datetime') - datetime_parcel_patch = patch('parcel.datetime') + datetime_patch = patch('gioland.forms.datetime') + datetime_parcel_patch = patch('gioland.parcel.datetime') self.mock_datetime = datetime_patch.start() self.mock_parcel_datetime = datetime_parcel_patch.start() self.addCleanup(datetime_patch.stop) @@ -568,7 +568,7 @@ def test_search_with_country_argument_filters_by_country(self): self.assertItemsEqual(resp['parcels'], [name]) def test_get_parcel_metadata(self): - import warehouse + from gioland import warehouse name = self.new_parcel() resp = self.get_json('/api/parcel/' + name) with self.app.test_request_context(): diff --git a/tests/permissions_test.py b/tests/permissions_test.py index 6ce4d5c..53bfa15 100644 --- a/tests/permissions_test.py +++ b/tests/permissions_test.py @@ -1,13 +1,14 @@ -from StringIO import StringIO -from mock import patch, call import flask +from StringIO import StringIO from common import AppTestCase, record_events, select -from definitions import COUNTRY, LOT, STREAM +from mock import patch, call + +from gioland.definitions import COUNTRY, LOT, STREAM def setUpModule(self): - import parcel - import warehouse + from gioland import parcel + from gioland import warehouse self.parcel = parcel self.warehouse = warehouse @@ -23,7 +24,7 @@ def remove_from_role(self, username, role_name): if u != 'user_id:%s' % username] def create_parcel(self, stage=None, delivery_type=LOT): - with patch('auth.authorize'): + with patch('gioland.auth.authorize'): if delivery_type == COUNTRY: post_resp = self.client.post('parcel/new/country', data=self.COUNTRY_METADATA) @@ -329,12 +330,12 @@ class RolesTest(AppTestCase): def setUp(self): self.app.config['LDAP_SERVER'] = 'ldap://some.ldap.server' - UsersDB_patch = patch('auth.UsersDB') + UsersDB_patch = patch('gioland.auth.UsersDB') self.mock_UsersDB = UsersDB_patch.start() self.addCleanup(UsersDB_patch.stop) def test_users_db_connection(self): - import auth + from gioland import auth mock_udb = self.mock_UsersDB.return_value mock_udb.member_roles_info.return_value = [] with self.app.test_request_context(): @@ -343,7 +344,7 @@ def test_users_db_connection(self): call(ldap_server='some.ldap.server')) def test_role_list_fetched_from_ldap(self): - import auth + from gioland import auth mock_udb = self.mock_UsersDB.return_value mock_udb.member_roles_info.return_value = [ ('eionet', None), @@ -359,7 +360,7 @@ def test_role_list_fetched_from_ldap(self): [call('user', 'somebody')]) def test_authorize_looks_into_ldap_groups(self): - import auth + from gioland import auth mock_udb = self.mock_UsersDB.return_value mock_udb.member_roles_info.return_value = [('eionet-nrc', None)] self.app.config['ROLE_NRC'] = ['ldap_group:eionet-nrc'] @@ -370,7 +371,7 @@ def test_authorize_looks_into_ldap_groups(self): self.assertTrue(auth.authorize(['ROLE_NRC'])) def test_authorize_for_anonymous_returns_false(self): - import auth + from gioland import auth self.app.config['ROLE_ETC'] = ['user_id:somebody'] with self.app.test_request_context(): self.app.preprocess_request() @@ -380,7 +381,7 @@ def test_authorize_for_anonymous_returns_false(self): class RequireAdminTest(AppTestCase): def setUp(self): - import auth + from gioland import auth @self.app.route('/some_view') @auth.require_admin diff --git a/tests/storage_test.py b/tests/storage_test.py index 4b091f8..b57e19d 100644 --- a/tests/storage_test.py +++ b/tests/storage_test.py @@ -1,11 +1,13 @@ -import unittest import tempfile -from datetime import datetime +import unittest from contextlib import contextmanager -from path import path +from datetime import datetime + import transaction from common import AppTestCase -from definitions import COUNTRY_EXCLUDE_METADATA +from path import path + +from gioland.definitions import COUNTRY_EXCLUDE_METADATA BAD_METADATA_VALUES = [ {2: 'a'}, @@ -16,7 +18,7 @@ def setUpModule(self): - import warehouse + from gioland import warehouse self.warehouse = warehouse @@ -274,7 +276,7 @@ def create_initial_parcel(self): return parcel def test_delete_removes_subsequent_parcels(self): - from parcel import finalize_parcel, delete_parcel_and_followers + from gioland.parcel import finalize_parcel, delete_parcel_and_followers parcel = self.create_initial_parcel() finalize_parcel(self.wh, parcel, reject=False) parcel2 = self.wh.get_parcel(parcel.metadata['next_parcel']) @@ -282,7 +284,7 @@ def test_delete_removes_subsequent_parcels(self): self.assertRaises(KeyError, self.wh.get_parcel, parcel2.name) def test_delete_keeps_previous_parcels(self): - from parcel import finalize_parcel, delete_parcel_and_followers + from gioland.parcel import finalize_parcel, delete_parcel_and_followers parcel = self.create_initial_parcel() finalize_parcel(self.wh, parcel, reject=False) parcel2 = self.wh.get_parcel(parcel.metadata['next_parcel']) @@ -292,7 +294,7 @@ def test_delete_keeps_previous_parcels(self): self.assertIs(self.wh.get_parcel(parcel.name), parcel) def test_delete_leaves_previous_parcel_unfinalized(self): - from parcel import finalize_parcel, delete_parcel_and_followers + from gioland.parcel import finalize_parcel, delete_parcel_and_followers parcel = self.create_initial_parcel() finalize_parcel(self.wh, parcel, reject=False) parcel2 = self.wh.get_parcel(parcel.metadata['next_parcel']) @@ -302,7 +304,7 @@ def test_delete_leaves_previous_parcel_unfinalized(self): self.assertNotIn('upload_time', parcel.metadata) def test_delete_adds_comment_on_previous_parcel(self): - from parcel import finalize_parcel, delete_parcel_and_followers + from gioland.parcel import finalize_parcel, delete_parcel_and_followers parcel = self.create_initial_parcel() finalize_parcel(self.wh, parcel, reject=False) parcel2 = self.wh.get_parcel(parcel.metadata['next_parcel']) @@ -402,7 +404,7 @@ def create_parcel(self, stage, finalize_and_link=False): return parcel.name def symlink_path(self, metadata, *extra): - from definitions import EDITABLE_METADATA + from gioland.definitions import EDITABLE_METADATA filtered_metadata = tuple(set(EDITABLE_METADATA) ^ set(COUNTRY_EXCLUDE_METADATA)) symlink_path = self.symlinks_root for name in filtered_metadata: diff --git a/tests/upload_test.py b/tests/upload_test.py index e53e1af..d27ee71 100644 --- a/tests/upload_test.py +++ b/tests/upload_test.py @@ -1,4 +1,5 @@ import json + from StringIO import StringIO from common import AppTestCase, authorization_patch, select @@ -184,7 +185,7 @@ def create_chunks_for_parcel(self, parcel): return temp def test_create_file_from_chunks(self): - from parcel import create_file_from_chunks + from gioland.parcel import create_file_from_chunks resp = self.client.post('/parcel/new/country', data=self.PARCEL_METADATA) parcel_name = resp.location.rsplit('/', 1)[-1] with self.app.test_request_context():