Skip to content

Commit

Permalink
Merge branch 'master' into fix-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
taliaga committed Sep 10, 2019
2 parents 53b0c35 + a65c203 commit d720299
Show file tree
Hide file tree
Showing 73 changed files with 3,872 additions and 284 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
omit = */tests/*
*/test/*

9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ services:

install:
- docker --version
- pip install pipenv

before_script:
- pipenv install

script:
- source deps.env
- source setup_dev_env.sh
- sh run_tests.sh

after_success:
- coveralls

notifications:
email: false
8 changes: 6 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ name = "pypi"

[packages]
certifi = "==2018.10.15"
connexion = "~=2.2"
"connexion[swagger-ui]" = "~=2.2"
crate = "~=0.22"
flask = "~=0.12"
flask = "~=1.1.0"
geocoder = "~=1.33"
geojson = "~=2.4"
geomet = "~=0.2"
influxdb = "~=4.0"
pg8000 = ">=1.13"
pymongo = "~=3.4"
pytest = "~=3.0"
pytest-cov = "~=2.7.1"
coveralls = "~=1.7.0"
pytest-flask = "~=0.10"
python-dateutil = ">=2.7"
pyyaml = ">=4.2"
Expand Down
254 changes: 178 additions & 76 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<br/>
[![Documentation badge](https://img.shields.io/readthedocs/quantumleap.svg)](https://quantumleap.readthedocs.io/en/latest/)
[![Build Status](https://travis-ci.org/smartsdk/ngsi-timeseries-api.svg?branch=master)](https://travis-ci.org/smartsdk/ngsi-timeseries-api?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/smartsdk/ngsi-timeseries-api/badge.svg?branch=master)](https://coveralls.io/github/smartsdk/ngsi-timeseries-api?branch=master)
![Status](https://nexus.lab.fiware.org/static/badges/statuses/quantum-leap.svg)
[![Swagger Validator](https://img.shields.io/swagger/valid/2.0/https/raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore-expanded.json.svg)](https://app.swaggerhub.com/apis/smartsdk/ngsi-tsdb)

Expand Down
23 changes: 23 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# QuantumLeap Release Notes

## 0.7.4

- Fix bug with Custom Time Index header handling (#247)
- Timescale backend fixes (#243 #246)
- Bring back /ui endpoint (#229)
- Update dependencies (#244)

## 0.7.3

- Relax Crate health check (#239)
- Timescale backend teething troubles (#237)
- add coverall badge (#236)
- Coverage tool integration with travis (#221)

## 0.7.2

- Initial Timescale DB support (#231)

## 0.7.1

- Japanses Translations Update (#220)
- Remove OSM checks by default (#226)

## 0.7.0

- Flatten JSON in query results (#213)
Expand Down
13 changes: 9 additions & 4 deletions setup_dev_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ docker build -t quantumleap .

source deps.env

# Aliasing so that notifications from orion container reach dev localhost
LH=192.0.0.1
sudo ifconfig lo0 alias $LH
LH=`( /sbin/ifconfig eth0 | grep 'inet' | cut -d: -f2 | awk '{ print $1}' ) 2> /dev/null`
if [ -z "$LH" ]
then
# Aliasing so that notifications from orion container reach dev localhost
LH=192.0.0.1
sudo ifconfig lo0 alias $LH
fi

export ORION_HOST=$LH
export MONGO_HOST=$LH

export QL_HOST=$LH
export CRATE_HOST=$LH
export POSTGRES_HOST=$LH
export INFLUX_HOST=$LH
export RETHINK_HOST=$LH

export REDIS_HOST=$LH

pipenv shell
[[ "$LH" != "192.0.0.1" ]] || pipenv shell
3 changes: 3 additions & 0 deletions specification/quantumleap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,22 @@ parameters:
in: query
name: lastN
type: integer
minimum: 1
description: "Optional. Used to request only the last N values that satisfy
the request conditions."
limit:
in: query
name: limit
type: integer
minimum: 1
default: 10000
description: "Optional. Maximum number of results to retrieve in a single
response."
offset:
in: query
name: offset
type: integer
minimum: 0
description: "Optional. Offset to apply to the response results. For
example, if the query was to return 10 results and you use an offset of
1, the response will return the last 9 values. Make sure you don't give
Expand Down
12 changes: 6 additions & 6 deletions src/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ class QLError(Exception):
"""


class UnsupportedOption(QLError):
"""
Used to flag usage of an unsupported/invalid option in any of the methods.
"""


class NGSIUsageError(QLError):
"""
Errors due to wrong NGSI usage.
Expand All @@ -21,9 +27,3 @@ def __init__(self, entity_id=''):
msg = "There are multiple entities with the given entity_id {}. " \
"Please specify entity_type."
NGSIUsageError.__init__(self, msg.format(entity_id))


class UnsupportedOption(QLError):
"""
Used to flag usage of an unsupported/invalid option in any of the methods.
"""
Empty file.
Empty file.
106 changes: 106 additions & 0 deletions src/geocoding/geojson/tests/test_wktcodec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
from geocoding.geojson.wktcodec import *
import pytest

# NOTE. GeoJSON below comes from: https://en.wikipedia.org/wiki/GeoJSON

geoj_point = {
'type': 'Point',
'coordinates': [30, 10]
}

wkt_point = 'POINT (30 10)'

geoj_linestring = {
'type': 'LineString',
'coordinates': [
[30, 10], [10, 30], [40, 40]
]
}
wkt_linestring = 'LINESTRING (30 10, 10 30, 40 40)'

geoj_polygon = {
'type': 'Polygon',
'coordinates': [
[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]
]
}

wkt_polygon = 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))'

geoj_polygon_with_hole = {
'type': 'Polygon',
'coordinates': [
[[35, 10], [45, 45], [15, 40], [10, 20], [35, 10]],
[[20, 30], [35, 35], [30, 20], [20, 30]]
]
}

wkt_polygon_with_hole = 'POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), ' + \
'(20 30, 35 35, 30 20, 20 30))'

geoj_geom_collection = {
'type': 'GeometryCollection',
'geometries': [
{
'type': 'Point',
'coordinates': [40, 10]
},
{
'type': 'LineString',
'coordinates': [
[10, 10], [20, 20], [10, 40]
]
},
{
'type': 'Polygon',
'coordinates': [
[[40, 40], [20, 45], [45, 30], [40, 40]]
]
}
]
}

wkt_geom_collection = 'GEOMETRYCOLLECTION (POINT (40 10),' + \
'LINESTRING (10 10, 20 20, 10 40),' + \
'POLYGON ((40 40, 20 45, 45 30, 40 40)))'


@pytest.mark.parametrize('input_geoj, expected_wkt', [
(geoj_point, wkt_point),
(geoj_linestring, wkt_linestring),
(geoj_polygon, wkt_polygon),
(geoj_polygon_with_hole, wkt_polygon_with_hole),
(geoj_geom_collection, wkt_geom_collection)
])
def test_encode_as_wkt(input_geoj, expected_wkt):
assert encode_as_wkt(input_geoj, decimals=0) == expected_wkt


@pytest.mark.parametrize('input_geoj', [
geoj_point, geoj_linestring, geoj_polygon, geoj_polygon_with_hole,
geoj_geom_collection
])
def test_encode_as_wkt_then_decode(input_geoj):
wkt_str = encode_as_wkt(input_geoj)
decoded_geoj = decode_wkt(wkt_str)
assert decoded_geoj == input_geoj


@pytest.mark.parametrize('input_geoj', [
geoj_point, geoj_linestring, geoj_polygon, geoj_polygon_with_hole,
geoj_geom_collection
])
def test_encode_as_wkb_then_decode(input_geoj):
wkb_bytes = encode_as_wkb(input_geoj)
decoded_geoj = decode_wkb(wkb_bytes)
assert decoded_geoj == input_geoj


@pytest.mark.parametrize('input_geoj', [
geoj_point, geoj_linestring, geoj_polygon, geoj_polygon_with_hole,
geoj_geom_collection
])
def test_encode_as_wkb_hex_then_decode(input_geoj):
wkb_hex = encode_as_wkb_hex(input_geoj)
decoded_geoj = decode_wkb_hexstr(wkb_hex)
assert decoded_geoj == input_geoj
Loading

0 comments on commit d720299

Please sign in to comment.