-
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 tests for publishing data-stream
Add tests for publishing individual parametric and nonparametric datastreams Signed-off-by: Osman Hadzic <osman.hadzic@secomind.com>
- Loading branch information
1 parent
80aa547
commit 2715530
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
...ice_publish_datastream/test_app_engine_device_publish_datastream_individual_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,86 @@ | ||
# SPDX-FileCopyrightText: 2024 SECO Mind Srl | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import subprocess | ||
|
||
from resources import ( | ||
list_of_params_endpoints, | ||
list_of_nonparams_endpoints, | ||
map_of_params_data, | ||
map_of_nonparams_data, | ||
list_of_nonparams_endpoints, | ||
) | ||
|
||
|
||
def test_app_engine_server_publish_datastream_individual_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.individual.parametric.Datastream" | ||
|
||
for path in list_of_params_endpoints: | ||
value = map_of_params_data[path] | ||
if type(value) is type([]): | ||
value = " ".join(value).replace(" ", ",") | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"devices", | ||
"publish-datastream", | ||
device_id, | ||
interface_name, | ||
path, | ||
value, | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
] | ||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
print(f"Info: {sample_data_result.stdout}") | ||
assert sample_data_result.stdout.replace("\n", "") == "ok" | ||
|
||
|
||
def test_app_engine_server_publish_datastream_individual_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.individual.nonparametric.Datastream" | ||
|
||
for path in list_of_nonparams_endpoints: | ||
value = map_of_nonparams_data[path] | ||
if type(value) is type([]): | ||
value = " ".join(value).replace(" ", ",") | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"devices", | ||
"publish-datastream", | ||
device_id, | ||
interface_name, | ||
path, | ||
value, | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
] | ||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
print(f"Info: {sample_data_result.stdout}") | ||
assert sample_data_result.stdout.replace("\n", "") == "ok" |