Skip to content

Commit

Permalink
Update tests, add invalid gps entry for post processing user editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
xbgmsharp committed Nov 3, 2024
1 parent ea89c93 commit 5d21cb2
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 15 deletions.
12 changes: 12 additions & 0 deletions tests/metrics_sample_aava.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@
"status" : "sailing",
"metrics" : {"navigation.log": 17441766, "navigation.trip.log": 80747, "navigation.headingTrue": 3.5972, "navigation.gnss.satellites": 10, "environment.depth.belowKeel": 20.948999999999998, "navigation.magneticVariation": 0.1414, "navigation.speedThroughWater": 3.47, "environment.water.temperature": 313.15, "electrical.batteries.1.current": 192.4, "electrical.batteries.1.voltage": 14.56, "navigation.gnss.antennaAltitude": 0.39, "network.n2k.ngt-1.130356.errorID": 0, "network.n2k.ngt-1.130356.modelID": 14, "environment.depth.belowTransducer": 20.95, "electrical.batteries.1.temperature": 299.82, "environment.depth.transducerToKeel": -0.001, "navigation.gnss.horizontalDilution": 0.8, "network.n2k.ngt-1.130356.ch1.rxLoad": 4, "network.n2k.ngt-1.130356.ch1.txLoad": 0, "network.n2k.ngt-1.130356.ch2.rxLoad": 0, "network.n2k.ngt-1.130356.ch2.txLoad": 64, "network.n2k.ngt-1.130356.ch1.deleted": 0, "network.n2k.ngt-1.130356.ch2.deleted": 0, "network.n2k.ngt-1.130356.ch2Bandwidth": 3, "network.n2k.ngt-1.130356.ch1.bandwidth": 2, "network.n2k.ngt-1.130356.ch1.rxDropped": 0, "network.n2k.ngt-1.130356.ch2.rxDropped": 0, "network.n2k.ngt-1.130356.ch1.rxFiltered": 0, "network.n2k.ngt-1.130356.ch2.rxFiltered": 0, "network.n2k.ngt-1.130356.ch1.rxBandwidth": 4, "network.n2k.ngt-1.130356.ch1.txBandwidth": 0, "network.n2k.ngt-1.130356.ch2.rxBandwidth": 0, "network.n2k.ngt-1.130356.ch2.txBandwidth": 10, "network.n2k.ngt-1.130356.uniChannelCount": 2, "network.n2k.ngt-1.130356.indiChannelCount": 2, "network.n2k.ngt-1.130356.ch1.BufferLoading": 0, "network.n2k.ngt-1.130356.ch2.bufferLoading": 0, "network.n2k.ngt-1.130356.ch1.PointerLoading": 0, "network.n2k.ngt-1.130356.ch2.pointerLoading": 0}
},
{
"time" : "2022-07-31T11:41:28.561Z",
"client_id" : "vessels.urn:mrn:imo:mmsi:987654321",
"latitude" : 59.7163052,
"longitude" : 25.7325741,
"speedoverground" : 9.5,
"courseovergroundtrue" : 198.8,
"windspeedapparent" : 18.0,
"anglespeedapparent" : 41.0,
"status" : "sailing",
"metrics" : {"navigation.log": 17441766, "navigation.trip.log": 80747, "navigation.headingTrue": 3.5972, "navigation.gnss.satellites": 10, "environment.depth.belowKeel": 20.948999999999998, "navigation.magneticVariation": 0.1414, "navigation.speedThroughWater": 3.47, "environment.water.temperature": 313.15, "electrical.batteries.1.current": 192.4, "electrical.batteries.1.voltage": 14.56, "navigation.gnss.antennaAltitude": 0.39, "network.n2k.ngt-1.130356.errorID": 0, "network.n2k.ngt-1.130356.modelID": 14, "environment.depth.belowTransducer": 20.95, "electrical.batteries.1.temperature": 299.82, "environment.depth.transducerToKeel": -0.001, "navigation.gnss.horizontalDilution": 0.8, "network.n2k.ngt-1.130356.ch1.rxLoad": 4, "network.n2k.ngt-1.130356.ch1.txLoad": 0, "network.n2k.ngt-1.130356.ch2.rxLoad": 0, "network.n2k.ngt-1.130356.ch2.txLoad": 64, "network.n2k.ngt-1.130356.ch1.deleted": 0, "network.n2k.ngt-1.130356.ch2.deleted": 0, "network.n2k.ngt-1.130356.ch2Bandwidth": 3, "network.n2k.ngt-1.130356.ch1.bandwidth": 2, "network.n2k.ngt-1.130356.ch1.rxDropped": 0, "network.n2k.ngt-1.130356.ch2.rxDropped": 0, "network.n2k.ngt-1.130356.ch1.rxFiltered": 0, "network.n2k.ngt-1.130356.ch2.rxFiltered": 0, "network.n2k.ngt-1.130356.ch1.rxBandwidth": 4, "network.n2k.ngt-1.130356.ch1.txBandwidth": 0, "network.n2k.ngt-1.130356.ch2.rxBandwidth": 0, "network.n2k.ngt-1.130356.ch2.txBandwidth": 10, "network.n2k.ngt-1.130356.uniChannelCount": 2, "network.n2k.ngt-1.130356.indiChannelCount": 2, "network.n2k.ngt-1.130356.ch1.BufferLoading": 0, "network.n2k.ngt-1.130356.ch2.bufferLoading": 0, "network.n2k.ngt-1.130356.ch1.PointerLoading": 0, "network.n2k.ngt-1.130356.ch2.pointerLoading": 0}
},
{
"time" : "2022-07-31T11:42:28.569Z",
"client_id" : "vessels.urn:mrn:imo:mmsi:987654321",
Expand Down
6 changes: 6 additions & 0 deletions tests/sql/cron_post_jobs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ SELECT extra FROM api.logbook l WHERE id = 1 AND vessel_id = current_setting('ve
SELECT api.update_logbook_observations_fn(1, '{"tags": ["tag_name"]}'::TEXT);
SELECT extra FROM api.logbook l WHERE id = 1 AND vessel_id = current_setting('vessel.id', false);

\echo 'Check numbers of geojson properties'
SELECT jsonb_object_keys(jsonb_path_query(track_geojson, '$.features[0].properties'))
FROM api.logbook where id = 1 AND vessel_id = current_setting('vessel.id', false);
SELECT jsonb_object_keys(jsonb_path_query(track_geojson, '$.features[1].properties'))
FROM api.logbook where id = 1 AND vessel_id = current_setting('vessel.id', false);

-- Check export
--\echo 'check logbook export fn'
--SELECT api.export_logbook_geojson_fn(1);
Expand Down
61 changes: 56 additions & 5 deletions tests/sql/cron_post_jobs.sql.output
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ SELECT 1
-[ RECORD 1 ]+----------
name | "kapla"
count | 4
max_speed | 7.1
max_distance | 8.8968
max_speed | 9.5
max_distance | 68.8677
max_duration | "PT1H11M"
?column? | 3
?column? | 30.1154
?column? | "PT2H43M"
?column? | 90.6030
?column? | "PT2H44M"
?column? | 44.2
?column? | 2
?column? | 3
?column? | 4
?column? | 4
first_date | t
Expand Down Expand Up @@ -110,3 +110,54 @@ update_logbook_observations_fn | t
-[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
extra | {"tags": ["tag_name"], "metrics": {"propulsion.main.runTime": "PT10S"}, "observations": {"seaState": -1, "visibility": -1, "cloudCoverage": 1}, "avg_wind_speed": 14.549999999999999}

Check numbers of geojson properties
-[ RECORD 1 ]-----+-----------------
jsonb_object_keys | id
-[ RECORD 2 ]-----+-----------------
jsonb_object_keys | name
-[ RECORD 3 ]-----+-----------------
jsonb_object_keys | notes
-[ RECORD 4 ]-----+-----------------
jsonb_object_keys | _to_time
-[ RECORD 5 ]-----+-----------------
jsonb_object_keys | distance
-[ RECORD 6 ]-----+-----------------
jsonb_object_keys | duration
-[ RECORD 7 ]-----+-----------------
jsonb_object_keys | avg_speed
-[ RECORD 8 ]-----+-----------------
jsonb_object_keys | max_speed
-[ RECORD 9 ]-----+-----------------
jsonb_object_keys | _from_time
-[ RECORD 10 ]----+-----------------
jsonb_object_keys | _to_moorage_id
-[ RECORD 11 ]----+-----------------
jsonb_object_keys | avg_wind_speed
-[ RECORD 12 ]----+-----------------
jsonb_object_keys | max_wind_speed
-[ RECORD 13 ]----+-----------------
jsonb_object_keys | _from_moorage_id

-[ RECORD 1 ]-----+---------------------
jsonb_object_keys | time
-[ RECORD 2 ]-----+---------------------
jsonb_object_keys | trip
-[ RECORD 3 ]-----+---------------------
jsonb_object_keys | notes
-[ RECORD 4 ]-----+---------------------
jsonb_object_keys | status
-[ RECORD 5 ]-----+---------------------
jsonb_object_keys | latitude
-[ RECORD 6 ]-----+---------------------
jsonb_object_keys | longitude
-[ RECORD 7 ]-----+---------------------
jsonb_object_keys | truewindspeed
-[ RECORD 8 ]-----+---------------------
jsonb_object_keys | speedoverground
-[ RECORD 9 ]-----+---------------------
jsonb_object_keys | truewinddirection
-[ RECORD 10 ]----+---------------------
jsonb_object_keys | windspeedapparent
-[ RECORD 11 ]----+---------------------
jsonb_object_keys | courseovergroundtrue

2 changes: 1 addition & 1 deletion tests/sql/cron_run_jobs.sql.output
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ any_pending_jobs | 2

Check the number of metrics entries
-[ RECORD 1 ]-+----
metrics_count | 172
metrics_count | 173

6 changes: 3 additions & 3 deletions tests/sql/monitoring.sql.output
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ count | 21

Test monitoring_view3 for user
-[ RECORD 1 ]
count | 3736
count | 3775

Test monitoring_voltage for user
-[ RECORD 1 ]
count | 47
count | 48

Test monitoring_temperatures for user
-[ RECORD 1 ]
count | 120
count | 121

Test monitoring_humidity for user
-[ RECORD 1 ]
Expand Down
12 changes: 6 additions & 6 deletions tests/sql/qgis.sql.output
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ Get BBOX Extent from SQL query for a log: "^/log_(w+)_(d+).png$"
qgis_bbox_py_fn | 2556155.0636042403,8365608,2660086.9363957597,8420076

-[ RECORD 1 ]---+----------------------------------------------------
qgis_bbox_py_fn | 2749398.035335689,8334944,2756917.964664311,8338885
qgis_bbox_py_fn | 2745681,8303937.662962963,2871529,8369891.337037037

Get BBOX Extent from SQL query for a log as line: "^/log_(w+)_(d+)_line.png$"
-[ RECORD 1 ]---+-------------------------------------------------------------------------
qgis_bbox_py_fn | 2570800.6277114027,8368634.173700442,2645441.4677270483,8417049.85371059

-[ RECORD 1 ]---+--------------------------------------------------------------------------
qgis_bbox_py_fn | 2750457.4431765806,8335162.530580978,2755858.0759322727,8338665.643719805
-[ RECORD 1 ]---+-----------------------------------------------------------------------
qgis_bbox_py_fn | 2752672.6236475753,8300633.73408079,2864537.04561218,8373194.440219993

Get BBOX Extent from SQL query for all logs by vessel_id: "^/logs_(w+)_(d+).png$"
-[ RECORD 1 ]---+------------------------------------------------------
qgis_bbox_py_fn | 2556155.0636042403,8365608,2660086.9363957597,8420076

-[ RECORD 1 ]---+------------------------------------------------------
qgis_bbox_py_fn | -2006284.4558303887,4864146,5013530.455830389,8543049
qgis_bbox_py_fn | -1950837.4558303887,4864146,5068977.455830389,8543049

Get BBOX Extent from SQL query for a trip by vessel_id: "^/trip_(w+)_(d+)_(d+).png$"
-[ RECORD 1 ]---+-------------------------------------
qgis_bbox_py_fn | 2595383,4787988.0,2620859,11997696.0

-[ RECORD 1 ]---+---------------------------------------
qgis_bbox_py_fn | 97351,-192283890.5,2909895,205691085.5
qgis_bbox_py_fn | 90420,-201110377.5,3027720,214517572.5

Get BBOX Extent from SQL query for a trip by vessel_id: "^/trip_((w+)_(d+)_(d+)).png$"
-[ RECORD 1 ]--------+------------------------------------------------------
qgis_bbox_trip_py_fn | 2556155.0636042403,8365608,2660086.9363957597,8420076

-[ RECORD 1 ]--------+------------------------------------------------------
qgis_bbox_trip_py_fn | -2006284.4558303887,4864146,5013530.455830389,8543049
qgis_bbox_trip_py_fn | -1950837.4558303887,4864146,5068977.455830389,8543049

-[ RECORD 1 ]
count | 3
Expand Down

0 comments on commit 5d21cb2

Please sign in to comment.