Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit 8ac4673

Browse files
authored
Merge pull request #27 from fabianazioti/rv04
reviewing for release
2 parents 1b4a41d + bccaf0e commit 8ac4673

File tree

15 files changed

+89
-189
lines changed

15 files changed

+89
-189
lines changed

CHANGES.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
Changes
1111
=======
1212

13-
Version 0.2.0 (2020-12-11)
14-
--------------------------
13+
Version 0.4.0-0 (2020-12-11)
14+
----------------------------
1515

1616

1717
- First experimental version.

INSTALL.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ In the source code folder, enter the following command:
133133
134134
$ FLASK_APP="wlts" \
135135
FLASK_ENV="development" \
136-
SQLALCHEMY_DATABASE_URI="postgresql://user:password@localhost:5432/dbname" \
137136
WLTS_URL="http://localhost:5000" \
138137
flask run
139138
@@ -143,9 +142,6 @@ You may need to replace the definition of some environment variables:
143142

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

146-
- ``SQLALCHEMY_DATABASE_URI="postgresql://user:password@localhost:5432/dbname"``: The database URI to be used.
147-
148-
149145
The above command should output some messages in the console as showed below:
150146

151147
.. code-block:: shell
@@ -193,7 +189,6 @@ Enter the following command to run the service:
193189
.. code-block:: shell
194190
195191
WLTS_URL="http://localhost:5000" \
196-
SQLALCHEMY_DATABASE_URI=""postgresql://user:password@localhost:5432/dbname" \
197192
wlts run
198193
199194

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Web Land Trajectory Service
2929
:target: https://wlts-server.readthedocs.io/en/latest/
3030
:alt: Documentation Status
3131

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

3636
.. image:: https://img.shields.io/github/tag/brazil-data-cube/wlts.svg/
@@ -86,7 +86,7 @@ License
8686
=======
8787

8888
.. admonition::
89-
Copyright (C) 2019 INPE.
89+
Copyright (C) 2019-2020 INPE.
9090

9191
Web Land Trajectory Service is free software; you can redistribute it and/or modify it
9292
under the terms of the MIT License; see LICENSE file for more details.

docker/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
FROM brazildatacube/base:0.1
22

3-
RUN apt-get update && apt-get install -y build-essential libpq-dev libgdal-dev manpages-dev git vim
4-
3+
RUN apt-get update && apt-get install -y build-essential libpq-dev libgdal-dev manpages-dev git vim \
4+
&& rm -rf /var/lib/apt/lists/*
5+
56
ADD . /wlts
67

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

2021
RUN pip install -e .[all]
22+
RUN pip install gunicorn
2123

2224
EXPOSE 5000
2325

24-
CMD [ "wlts", "run", "--host", "0.0.0.0" ]
26+
CMD ["gunicorn", "-w4", "--bind=0.0.0.0:5000", "wlts:app"]

docs/sphinx/license.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ License
1515
Contact
1616
=======
1717

18-
**Under Development!**
18+
19+
`Brazil Data Cube Team <mailto: brazildatacube@inpe.br>`_

setup.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646

4747
install_requires = [
4848
'Flask>=1.1.1',
49-
'Flask-Cors>=3.0.8',
50-
'Flask-Script>=2.0.6',
5149
'Flask-SQLAlchemy>=2.4.1',
5250
'GDAL>=2.2',
5351
'psycopg2>=2.8.3',
@@ -79,11 +77,7 @@
7977
zip_safe=False,
8078
include_package_data=True,
8179
platforms='any',
82-
entry_points={
83-
'console_scripts': [
84-
'wlts = wlts.cli:cli'
85-
]
86-
},
80+
entry_points={},
8781
extras_require=extras_require,
8882
install_requires=install_requires,
8983
setup_requires=setup_requires,
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
"""Unit-test for WLTS' controller."""
99
import pytest
10+
import os
1011

1112
from wlts.schemas import collections_list_response, \
1213
describe_collection_response, \
@@ -24,7 +25,10 @@ def client():
2425
yield client
2526

2627

27-
class TestListCollection:
28+
class TestWLTS:
29+
def test_data_dir(self):
30+
assert os.path.join(os.path.dirname(__file__), '/json_configs/datasources.json')
31+
2832
def list_collection(self, client):
2933
response = client.get('/wlts/list_collections')
3034

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

40-
collection_response = json_loads(response.data.decode('utf-8'))
44+
response_json = json_loads(response.data.decode('utf-8'))
4145

4246
assert response.status_code == 400
43-
assert collection_response['message'] == "\'collection_id\' is a required property"
47+
assert response_json['message'] == "\'collection_id\' is a required property"
4448

4549
def describe_collection(self, client):
4650
response = client.get(
47-
'/wlts/describe_collection?collection_id={}'.format("Prodes")
51+
'/wlts/describe_collection?collection_id={}'.format("deter_amz")
4852
)
4953

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

7276
assert response.status_code == 400
73-
assert collection_response['message'] == "\'latitude\' is a required propertyy"
77+
assert collection_response['message'] == "\'latitude\' is a required property"
7478

7579
def trajectory_without_long(self, client):
7680

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

8185
assert response.status_code == 400
82-
assert collection_response['message'] == "\'longitude\' is a required propertyy"
86+
assert collection_response['message'] == "\'longitude\' is a required property"
87+
88+
def trajectory(self, client):
89+
90+
response = client.get('/wlts/trajectoy?latitude=-9.091&longitude=-66.031')
91+
92+
response_json = json_loads(response.data.decode('utf-8'))
93+
94+
assert response.status_code == 200
95+
assert response.conten_type == "application/json"
96+
validate(instance=response_json, schema=trajectory_response)

wlts/__init__.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
#
88
"""Web Land Trajectory Service."""
99

10+
import os
11+
1012
from flask import Flask
11-
from flask_cors import CORS
13+
from werkzeug.exceptions import HTTPException, InternalServerError
1214

13-
from .blueprint import blueprint
1415
from .config import get_settings
15-
from .ext import WLTSDatabase
1616
from .version import __version__
1717

1818

19-
def create_app(config_name='DevelopmentConfig'):
19+
def create_app(config_name):
2020
"""Creates Brazil Data Cube WLTS application from config object.
2121
2222
:param config_name: Config instance.
@@ -26,18 +26,31 @@ def create_app(config_name='DevelopmentConfig'):
2626
"""
2727
app = Flask(__name__)
2828

29-
conf = get_settings(config_name)
29+
conf = config.get_settings(config_name)
3030
app.config.from_object(conf)
3131

32-
with app.app_context():
32+
setup_app(app)
33+
34+
return app
3335

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

36-
WLTSDatabase(app)
37+
def setup_app(app):
38+
@app.errorhandler(Exception)
39+
def handle_exception(e):
40+
"""Handle exceptions."""
41+
if isinstance(e, HTTPException):
42+
return {'code': e.code, 'description': e.description}, e.code
3743

38-
app.register_blueprint(blueprint)
44+
app.logger.exception(e)
45+
46+
return {'code': InternalServerError.code,
47+
'description': InternalServerError.description}, InternalServerError.code
48+
49+
from .views import bp
50+
51+
app.register_blueprint(bp)
3952

40-
return app
4153

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

4356
__all__ = ('__version__', 'create_app')

wlts/blueprint.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

wlts/cli.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)