Skip to content

Commit

Permalink
Merge pull request #27 from fabianazioti/rv04
Browse files Browse the repository at this point in the history
reviewing for release
  • Loading branch information
raphaelrpl authored Dec 11, 2020
2 parents 1b4a41d + bccaf0e commit 8ac4673
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 189 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
Changes
=======

Version 0.2.0 (2020-12-11)
--------------------------
Version 0.4.0-0 (2020-12-11)
----------------------------


- First experimental version.
Expand Down
5 changes: 0 additions & 5 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ In the source code folder, enter the following command:
$ FLASK_APP="wlts" \
FLASK_ENV="development" \
SQLALCHEMY_DATABASE_URI="postgresql://user:password@localhost:5432/dbname" \
WLTS_URL="http://localhost:5000" \
flask run
Expand All @@ -143,9 +142,6 @@ You may need to replace the definition of some environment variables:

- ``WLTS_URL="http://localhost:5000"``: Base URI of the service.

- ``SQLALCHEMY_DATABASE_URI="postgresql://user:password@localhost:5432/dbname"``: The database URI to be used.


The above command should output some messages in the console as showed below:

.. code-block:: shell
Expand Down Expand Up @@ -193,7 +189,6 @@ Enter the following command to run the service:
.. code-block:: shell
WLTS_URL="http://localhost:5000" \
SQLALCHEMY_DATABASE_URI=""postgresql://user:password@localhost:5432/dbname" \
wlts run
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Web Land Trajectory Service
:target: https://wlts-server.readthedocs.io/en/latest/
:alt: Documentation Status

.. image:: https://img.shields.io/badge/lifecycle-experimental-orange.svg
:target: https://www.tidyverse.org/lifecycle/#experimental
.. image:: https://img.shields.io/badge/lifecycle-maturing-blue.svg
:target: https://www.tidyverse.org/lifecycle/#maturing
:alt: Software Life Cycle

.. image:: https://img.shields.io/github/tag/brazil-data-cube/wlts.svg/
Expand Down Expand Up @@ -86,7 +86,7 @@ License
=======

.. admonition::
Copyright (C) 2019 INPE.
Copyright (C) 2019-2020 INPE.

Web Land Trajectory Service is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM brazildatacube/base:0.1

RUN apt-get update && apt-get install -y build-essential libpq-dev libgdal-dev manpages-dev git vim

RUN apt-get update && apt-get install -y build-essential libpq-dev libgdal-dev manpages-dev git vim \
&& rm -rf /var/lib/apt/lists/*

ADD . /wlts

WORKDIR /wlts
Expand All @@ -18,7 +19,8 @@ RUN pip install numpy==1.18.3
RUN pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option=$(gdal-config --cflags)

RUN pip install -e .[all]
RUN pip install gunicorn

EXPOSE 5000

CMD [ "wlts", "run", "--host", "0.0.0.0" ]
CMD ["gunicorn", "-w4", "--bind=0.0.0.0:5000", "wlts:app"]
3 changes: 2 additions & 1 deletion docs/sphinx/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ License
Contact
=======

**Under Development!**

`Brazil Data Cube Team <mailto: brazildatacube@inpe.br>`_
8 changes: 1 addition & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

install_requires = [
'Flask>=1.1.1',
'Flask-Cors>=3.0.8',
'Flask-Script>=2.0.6',
'Flask-SQLAlchemy>=2.4.1',
'GDAL>=2.2',
'psycopg2>=2.8.3',
Expand Down Expand Up @@ -79,11 +77,7 @@
zip_safe=False,
include_package_data=True,
platforms='any',
entry_points={
'console_scripts': [
'wlts = wlts.cli:cli'
]
},
entry_points={},
extras_require=extras_require,
install_requires=install_requires,
setup_requires=setup_requires,
Expand Down
26 changes: 20 additions & 6 deletions tests/test_controller.py → tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
"""Unit-test for WLTS' controller."""
import pytest
import os

from wlts.schemas import collections_list_response, \
describe_collection_response, \
Expand All @@ -24,7 +25,10 @@ def client():
yield client


class TestListCollection:
class TestWLTS:
def test_data_dir(self):
assert os.path.join(os.path.dirname(__file__), '/json_configs/datasources.json')

def list_collection(self, client):
response = client.get('/wlts/list_collections')

Expand All @@ -37,14 +41,14 @@ def list_collection(self, client):
def describe_collection_without_parameter(self, client):
response = client.get('/wlts/describe_collection')

collection_response = json_loads(response.data.decode('utf-8'))
response_json = json_loads(response.data.decode('utf-8'))

assert response.status_code == 400
assert collection_response['message'] == "\'collection_id\' is a required property"
assert response_json['message'] == "\'collection_id\' is a required property"

def describe_collection(self, client):
response = client.get(
'/wlts/describe_collection?collection_id={}'.format("Prodes")
'/wlts/describe_collection?collection_id={}'.format("deter_amz")
)

collection_response = json_loads(response.data.decode('utf-8'))
Expand All @@ -70,7 +74,7 @@ def trajectory_without_lat(self, client):
collection_response = json_loads(response.data.decode('utf-8'))

assert response.status_code == 400
assert collection_response['message'] == "\'latitude\' is a required propertyy"
assert collection_response['message'] == "\'latitude\' is a required property"

def trajectory_without_long(self, client):

Expand All @@ -79,4 +83,14 @@ def trajectory_without_long(self, client):
collection_response = json_loads(response.data.decode('utf-8'))

assert response.status_code == 400
assert collection_response['message'] == "\'longitude\' is a required propertyy"
assert collection_response['message'] == "\'longitude\' is a required property"

def trajectory(self, client):

response = client.get('/wlts/trajectoy?latitude=-9.091&longitude=-66.031')

response_json = json_loads(response.data.decode('utf-8'))

assert response.status_code == 200
assert response.conten_type == "application/json"
validate(instance=response_json, schema=trajectory_response)
33 changes: 23 additions & 10 deletions wlts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#
"""Web Land Trajectory Service."""

import os

from flask import Flask
from flask_cors import CORS
from werkzeug.exceptions import HTTPException, InternalServerError

from .blueprint import blueprint
from .config import get_settings
from .ext import WLTSDatabase
from .version import __version__


def create_app(config_name='DevelopmentConfig'):
def create_app(config_name):
"""Creates Brazil Data Cube WLTS application from config object.
:param config_name: Config instance.
Expand All @@ -26,18 +26,31 @@ def create_app(config_name='DevelopmentConfig'):
"""
app = Flask(__name__)

conf = get_settings(config_name)
conf = config.get_settings(config_name)
app.config.from_object(conf)

with app.app_context():
setup_app(app)

return app

CORS(app, resorces={r'/d/*': {"origins": '*'}})

WLTSDatabase(app)
def setup_app(app):
@app.errorhandler(Exception)
def handle_exception(e):
"""Handle exceptions."""
if isinstance(e, HTTPException):
return {'code': e.code, 'description': e.description}, e.code

app.register_blueprint(blueprint)
app.logger.exception(e)

return {'code': InternalServerError.code,
'description': InternalServerError.description}, InternalServerError.code

from .views import bp

app.register_blueprint(bp)

return app

app = create_app(os.environ.get('WLTS_ENVIRONMENT', 'DevelopmentConfig'))

__all__ = ('__version__', 'create_app')
18 changes: 0 additions & 18 deletions wlts/blueprint.py

This file was deleted.

62 changes: 0 additions & 62 deletions wlts/cli.py

This file was deleted.

1 change: 1 addition & 0 deletions wlts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TestingConfig(Config):
TESTING = True
DEBUG = True


key = Config.SECRET_KEY

CONFIG = {
Expand Down
2 changes: 1 addition & 1 deletion wlts/datasources/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from uuid import uuid4
from xml.dom import minidom

import gdal
import requests
from osgeo import gdal
from shapely.geometry import Point
from werkzeug.exceptions import NotFound

Expand Down
28 changes: 0 additions & 28 deletions wlts/ext.py

This file was deleted.

2 changes: 1 addition & 1 deletion wlts/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"""


__version__ = '0.2.0'
__version__ = '0.4.0-0'
Loading

0 comments on commit 8ac4673

Please sign in to comment.