Skip to content

Commit

Permalink
Update publish datastream tet
Browse files Browse the repository at this point in the history
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
osmanhadzic committed Dec 6, 2024
1 parent 5ee0021 commit 12ddb10
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
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="]
}
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
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)

0 comments on commit 12ddb10

Please sign in to comment.