-
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 device information retrieval
- Add test to list devices in realm - Add test to show information about a specific device - Add test to retrieve data snapshot from device Signed-off-by: Osman Hadzic <osman.hadzic@secomind.com>
- Loading branch information
1 parent
4d5608b
commit 52f4fc8
Showing
2 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
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,113 @@ | ||
# SPDX-FileCopyrightText: 2024 SECO Mind Srl | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import subprocess | ||
import json | ||
import re | ||
|
||
|
||
from resources import list_of_interface_names | ||
|
||
|
||
def test_app_engine_device_list(astarte_env_vars): | ||
astarte_url = astarte_env_vars["astarte_url"] | ||
realm = astarte_env_vars["realm"] | ||
jwt = astarte_env_vars["jwt"] | ||
device_test_1 = astarte_env_vars["device_test_1"] | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"devices", | ||
"list", | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
] | ||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
assert device_test_1 in sample_data_result.stdout | ||
|
||
|
||
def test_app_engine_device_show(astarte_env_vars): | ||
astarte_url = astarte_env_vars["astarte_url"] | ||
realm = astarte_env_vars["realm"] | ||
jwt = astarte_env_vars["jwt"] | ||
device_test_1 = astarte_env_vars["device_test_1"] | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"devices", | ||
"show", | ||
device_test_1, | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
] | ||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
|
||
assert device_test_1 in sample_data_result.stdout | ||
|
||
for key in list_of_interface_names: | ||
assert key in sample_data_result.stdout | ||
|
||
|
||
def test_app_engine_device_data_snapshot(astarte_env_vars): | ||
astarte_url = astarte_env_vars["astarte_url"] | ||
realm = astarte_env_vars["realm"] | ||
jwt = astarte_env_vars["jwt"] | ||
device_test_1 = astarte_env_vars["device_test_1"] | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"devices", | ||
"data-snapshot", | ||
device_test_1, | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
"-o", | ||
"json", | ||
] | ||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
|
||
json_value = json.loads(sample_data_result.stdout) | ||
|
||
for interface in list_of_interface_names: | ||
assert interface in json_value | ||
|
||
|
||
def test_app_engine_stats_device(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"] | ||
|
||
arg_list = [ | ||
"astartectl", | ||
"appengine", | ||
"stats", | ||
"device", | ||
"-t", | ||
jwt, | ||
"-u", | ||
astarte_url, | ||
"-r", | ||
realm, | ||
] | ||
|
||
sample_data_result = subprocess.run(arg_list, capture_output=True, text=True) | ||
except_output = "{TotalDevices:1 ConnectedDevices:0}\n" | ||
assert sample_data_result.stdout == except_output |
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