-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for publishing datastream with object aggregation type and server owned datastream. Signed-off-by: Osman Hadzic <osman.hadzic@secomind.com>
- Loading branch information
1 parent
5ee0021
commit 12ddb10
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
tests/app_engine/device/app_engine_device_publish_datastream/json_object.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"boolean": true, | ||
"integer": 44, | ||
"double": 123.45, | ||
"longinteger": 123456789012345, | ||
"string": "example string", | ||
"binaryblob": "aGVsbG8gd29ybGQ=", | ||
"datetime": "2024-09-09T09:09:09.900Z", | ||
"doublearray": [123.45, 678.9], | ||
"integerarray": [44, 456], | ||
"booleanarray": [true, false], | ||
"longintegerarray": [123456789012345, 678901234567890], | ||
"stringarray": ["string1", "string2"], | ||
"datetimearray": ["2024-09-09T09:09:09.900Z", "2024-09-10T09:09:09.900Z"], | ||
"binaryblobarray": ["aGVsbG8gd29ybGQ=", "d29ybGQgaGVsbG8="] | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/app_engine/device/app_engine_device_publish_datastream/json_object.json.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: 2024 SECO Mind Srl | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 |
79 changes: 79 additions & 0 deletions
79
..._device_publish_datastream/test_app_engine_device_publish_datastream_object_datastream.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# SPDX-FileCopyrightText: 2024 SECO Mind Srl | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import subprocess | ||
import json | ||
import os | ||
|
||
|
||
def test_app_engine_server_publish_datastream_object_parametric_datastream(astarte_env_vars): | ||
device_id = astarte_env_vars["device_test_1"] | ||
astarte_url = astarte_env_vars["astarte_url"] | ||
realm = astarte_env_vars["realm"] | ||
jwt = astarte_env_vars["jwt"] | ||
|
||
interface_name = "test.astarte-platform.server.object.parametric.Datastream" | ||
|
||
path = "/a" | ||
json_data = _read_json_data() | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"devices", | ||
"publish-datastream", | ||
device_id, | ||
interface_name, | ||
path, | ||
json_data, | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
] | ||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
assert sample_data_result.stdout.replace("\n", "") == "ok" | ||
|
||
|
||
def test_app_engine_server_publish_datastream_object_nonparametric_datastream(astarte_env_vars): | ||
device_id = astarte_env_vars["device_test_1"] | ||
astarte_url = astarte_env_vars["astarte_url"] | ||
realm = astarte_env_vars["realm"] | ||
jwt = astarte_env_vars["jwt"] | ||
|
||
interface_name = "test.astarte-platform.server.object.nonparametric.Datastream" | ||
|
||
path = "/the" | ||
json_data = _read_json_data() | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"devices", | ||
"publish-datastream", | ||
device_id, | ||
interface_name, | ||
path, | ||
json_data, | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
] | ||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
assert sample_data_result.stdout.replace("\n", "") == "ok" | ||
|
||
|
||
def _read_json_data(): | ||
json_path = "json_object" | ||
current_dir = os.path.dirname(__file__) | ||
json_path = os.path.join(current_dir, f"{json_path}.json") | ||
with open(json_path, "r") as file: | ||
data = json.load(file) | ||
return json.dumps(data) |