Skip to content

Commit

Permalink
Integrate travis
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreea Dima committed Sep 25, 2017
1 parent 7d6ed55 commit 12a22cb
Show file tree
Hide file tree
Showing 20 changed files with 159 additions and 127 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ sandbox/

# macOS auto-generated files
.DS_Store
.idea/

# Apache conf file
conf.d/virtual-host.conf
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
===========================
Expand Down
Empty file added gioland/__init__.py
Empty file.
9 changes: 5 additions & 4 deletions auth.py → gioland/auth.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion definitions.py → gioland/definitions.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
16 changes: 9 additions & 7 deletions forms.py → gioland/forms.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
13 changes: 7 additions & 6 deletions notification.py → gioland/notification.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
46 changes: 22 additions & 24 deletions parcel.py → gioland/parcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
10 changes: 5 additions & 5 deletions utils.py → gioland/utils.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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")
Expand Down
23 changes: 11 additions & 12 deletions warehouse.py → gioland/warehouse.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions manage.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -24,7 +24,7 @@


def register_monitoring_views(app):
import warehouse
from gioland import warehouse

@app.route('/ping')
def ping():
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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'])
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
15 changes: 8 additions & 7 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion tests/index_page_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from common import AppTestCase, authorization_patch, select
from definitions import LOT

from gioland.definitions import LOT


class UploadTest(AppTestCase):
Expand Down
Loading

0 comments on commit 12a22cb

Please sign in to comment.