Skip to content

Commit

Permalink
Fix incorrect endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Orru <simone.orru@secomind.com>
  • Loading branch information
sorru94 committed Sep 28, 2023
1 parent 4d9ae77 commit 191d86f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions e2etest/base/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def test_aggregate_from_device_to_server(device: DeviceMqtt, test_cfg: TestCfg):
color="cyan",
flush=True,
)
device.send_aggregate(test_cfg.interface_device_aggr, "/sensor-id", test_cfg.mock_data)
device.send_aggregate(test_cfg.interface_device_aggr, "/sensor_id", test_cfg.mock_data)

time.sleep(1)

cprint("\nChecking data stored on the server.", color="cyan", flush=True)
json_res = get_server_interface(test_cfg, test_cfg.interface_device_aggr)
parsed_res = json_res.get("data", {}).get("sensor-id")
parsed_res = json_res.get("data", {}).get("sensor_id")
if not parsed_res:
raise ValueError("Incorrectly formatted response from server")
if isinstance(parsed_res, list):
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_aggregate_from_server_to_device(test_cfg: TestCfg, rx_data_lock: Lock,
)

post_server_interface(
test_cfg, test_cfg.interface_server_aggr, "/sensor-id", test_cfg.mock_data
test_cfg, test_cfg.interface_server_aggr, "/sensor_id", test_cfg.mock_data
)

time.sleep(1)
Expand All @@ -101,7 +101,7 @@ def test_aggregate_from_server_to_device(test_cfg: TestCfg, rx_data_lock: Lock,
raise ValueError(
f"No data from this interface has been received {test_cfg.interface_server_aggr}"
)
parsed_rx_data = rx_data.get(test_cfg.interface_server_aggr).get("/sensor-id")
parsed_rx_data = rx_data.get(test_cfg.interface_server_aggr).get("/sensor_id")

# Make sure all the data has been correctly received
if parsed_rx_data != test_cfg.mock_data:
Expand Down
14 changes: 7 additions & 7 deletions e2etest/base/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_properties_from_device_to_server(device: DeviceMqtt, test_cfg: TestCfg)
"""
cprint("\nSet device owned properties.", color="cyan", flush=True)
for key, value in test_cfg.mock_data.items():
device.send(test_cfg.interface_device_prop, "/sensor-id/" + key, value)
device.send(test_cfg.interface_device_prop, "/sensor_id/" + key, value)
time.sleep(0.005)

time.sleep(1)

cprint("\nChecking data stored on the server.", color="cyan", flush=True)
json_res = get_server_interface(test_cfg, test_cfg.interface_device_prop)
parsed_res = json_res.get("data", {}).get("sensor-id")
parsed_res = json_res.get("data", {}).get("sensor_id")
if not parsed_res:
cprint(json_res, "red", flush=True)
raise ValueError("Incorrectly formatted response from server")
Expand All @@ -63,7 +63,7 @@ def test_properties_from_device_to_server(device: DeviceMqtt, test_cfg: TestCfg)
# Unset all the properties
cprint("\nUnset all the device owned properties.", color="cyan", flush=True)
for key, _ in test_cfg.mock_data.items():
device.unset_property(test_cfg.interface_device_prop, "/sensor-id/" + key)
device.unset_property(test_cfg.interface_device_prop, "/sensor_id/" + key)
time.sleep(0.005)

time.sleep(1)
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_properties_from_server_to_device(test_cfg: TestCfg, rx_data_lock: Lock,

for key, value in test_cfg.mock_data.items():
value = prepare_transmit_data(key, value)
post_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor-id/" + key, value)
post_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor_id/" + key, value)
time.sleep(0.005)

time.sleep(1)
Expand All @@ -107,14 +107,14 @@ def test_properties_from_server_to_device(test_cfg: TestCfg, rx_data_lock: Lock,
)
parsed_rx_data = rx_data.get(test_cfg.interface_server_prop)

if parsed_rx_data != {("/sensor-id/" + k): v for (k, v) in test_cfg.mock_data.items()}:
if parsed_rx_data != {("/sensor_id/" + k): v for (k, v) in test_cfg.mock_data.items()}:
cprint(parsed_rx_data, "red", flush=True)
raise ValueError("Incorrectly formatted response from server")

# Unset all the properties
cprint("\nUnset all the server owned properties.", color="cyan", flush=True)
for key, _ in test_cfg.mock_data.items():
delete_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor-id/" + key)
delete_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor_id/" + key)
time.sleep(0.005)

time.sleep(1)
Expand All @@ -128,6 +128,6 @@ def test_properties_from_server_to_device(test_cfg: TestCfg, rx_data_lock: Lock,
)
parsed_rx_data = rx_data.get(test_cfg.interface_server_prop)

if parsed_rx_data != {"/sensor-id/" + k: None for k in test_cfg.mock_data}:
if parsed_rx_data != {"/sensor_id/" + k: None for k in test_cfg.mock_data}:
cprint(parsed_rx_data, "red", flush=True)
raise ValueError("Incorrectly formatted response from server")
44 changes: 22 additions & 22 deletions e2etest/persistency/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ def set_all_properties(device: DeviceMqtt, test_cfg: TestCfg):
"""
cprint("\nSet device owned properties.", color="cyan", flush=True)
for key, value in test_cfg.mock_data.items():
device.send(test_cfg.interface_device_prop, "/sensor-id/" + key, value)
device.send(test_cfg.interface_device_prop, "/sensor_id/" + key, value)
time.sleep(0.005)

cprint("\nSet server owned properties.", color="cyan", flush=True)
for key, value in test_cfg.mock_data.items():
value = prepare_transmit_data(key, value)
post_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor-id/" + key, value)
post_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor_id/" + key, value)
time.sleep(0.005)


Expand All @@ -109,13 +109,13 @@ def unset_some_properties(device: DeviceMqtt, test_cfg: TestCfg):
cprint("\nUnset some device owned properties.", color="cyan", flush=True)
for key, _ in test_cfg.mock_data.items():
if key not in ["datetime_endpoint", "booleanarray_endpoint"]:
device.unset_property(test_cfg.interface_device_prop, "/sensor-id/" + key)
device.unset_property(test_cfg.interface_device_prop, "/sensor_id/" + key)
time.sleep(0.005)

cprint("\nUnset some server owned properties.", color="cyan", flush=True)
for key, _ in test_cfg.mock_data.items():
if key not in ["longinteger_endpoint", "stringarray_endpoint"]:
delete_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor-id/" + key)
delete_server_interface(test_cfg, test_cfg.interface_server_prop, "/sensor_id/" + key)
time.sleep(0.005)


Expand Down Expand Up @@ -143,19 +143,19 @@ def shuffle_database(persistency_dir: Path, test_cfg: TestCfg):
cursor = connection.cursor()
cursor.execute(
"DELETE FROM properties WHERE interface=? AND path=?",
(test_cfg.interface_device_prop, "/sensor-id/datetime_endpoint"),
(test_cfg.interface_device_prop, "/sensor_id/datetime_endpoint"),
)
cursor.execute(
"DELETE FROM properties WHERE interface=? AND path=?",
(test_cfg.interface_server_prop, "/sensor-id/longinteger_endpoint"),
(test_cfg.interface_server_prop, "/sensor_id/longinteger_endpoint"),
)
cursor.execute(
"INSERT OR REPLACE INTO properties (interface, major, path, value) VALUES " "(?, ?, ?, ?)",
(test_cfg.interface_device_prop, 0, "/sensor-id/integer_endpoint", pickle.dumps(66)),
(test_cfg.interface_device_prop, 0, "/sensor_id/integer_endpoint", pickle.dumps(66)),
)
cursor.execute(
"INSERT OR REPLACE INTO properties (interface, major, path, value) VALUES " "(?, ?, ?, ?)",
(test_cfg.interface_server_prop, 0, "/sensor-id/boolean_endpoint", pickle.dumps(True)),
(test_cfg.interface_server_prop, 0, "/sensor_id/boolean_endpoint", pickle.dumps(True)),
)
connection.commit()

Expand All @@ -167,11 +167,11 @@ def peek_astarte(test_cfg: TestCfg):
server_data = {}
cprint("\nReading data stored on the server.", color="cyan", flush=True)
json_res = get_server_interface(test_cfg, test_cfg.interface_device_prop)
server_data[test_cfg.interface_device_prop] = json_res.get("data", {}).get("sensor-id", {})
server_data[test_cfg.interface_device_prop] = json_res.get("data", {}).get("sensor_id", {})
parse_received_data(server_data[test_cfg.interface_device_prop])

json_res = get_server_interface(test_cfg, test_cfg.interface_server_prop)
server_data[test_cfg.interface_server_prop] = json_res.get("data", {}).get("sensor-id", {})
server_data[test_cfg.interface_server_prop] = json_res.get("data", {}).get("sensor_id", {})
parse_received_data(server_data[test_cfg.interface_server_prop])
return server_data

Expand Down Expand Up @@ -211,10 +211,10 @@ def main(cb_loop: asyncio.AbstractEventLoop, test_cfg: TestCfg):

actual_db = peek_database(persistency_dir, test_cfg.device_id)
expect_db = [
(test_cfg.interface_device_prop, 0, f"/sensor-id/{k}", v)
(test_cfg.interface_device_prop, 0, f"/sensor_id/{k}", v)
for k, v in test_cfg.mock_data.items()
] + [
(test_cfg.interface_server_prop, 0, f"/sensor-id/{k}", v)
(test_cfg.interface_server_prop, 0, f"/sensor_id/{k}", v)
for k, v in test_cfg.mock_data.items()
]
if actual_db != expect_db:
Expand All @@ -229,11 +229,11 @@ def main(cb_loop: asyncio.AbstractEventLoop, test_cfg: TestCfg):

actual_db = peek_database(persistency_dir, test_cfg.device_id)
expect_db = [
(test_cfg.interface_device_prop, 0, f"/sensor-id/{k}", v)
(test_cfg.interface_device_prop, 0, f"/sensor_id/{k}", v)
for k, v in test_cfg.mock_data.items()
if k in ["datetime_endpoint", "booleanarray_endpoint"]
] + [
(test_cfg.interface_server_prop, 0, f"/sensor-id/{k}", v)
(test_cfg.interface_server_prop, 0, f"/sensor_id/{k}", v)
for k, v in test_cfg.mock_data.items()
if k in ["longinteger_endpoint", "stringarray_endpoint"]
]
Expand Down Expand Up @@ -264,25 +264,25 @@ def main(cb_loop: asyncio.AbstractEventLoop, test_cfg: TestCfg):
(
"org.astarte-platform.python.e2etest.DeviceProperty",
0,
"/sensor-id/booleanarray_endpoint",
"/sensor_id/booleanarray_endpoint",
[True, False, True, False],
),
(
"org.astarte-platform.python.e2etest.ServerProperty",
0,
"/sensor-id/stringarray_endpoint",
"/sensor_id/stringarray_endpoint",
["hello", " world"],
),
(
"org.astarte-platform.python.e2etest.DeviceProperty",
0,
"/sensor-id/integer_endpoint",
"/sensor_id/integer_endpoint",
66,
),
(
"org.astarte-platform.python.e2etest.ServerProperty",
0,
"/sensor-id/boolean_endpoint",
"/sensor_id/boolean_endpoint",
True,
),
]
Expand All @@ -307,25 +307,25 @@ def main(cb_loop: asyncio.AbstractEventLoop, test_cfg: TestCfg):
(
"org.astarte-platform.python.e2etest.DeviceProperty",
0,
"/sensor-id/booleanarray_endpoint",
"/sensor_id/booleanarray_endpoint",
[True, False, True, False],
),
(
"org.astarte-platform.python.e2etest.DeviceProperty",
0,
"/sensor-id/integer_endpoint",
"/sensor_id/integer_endpoint",
66,
),
(
"org.astarte-platform.python.e2etest.ServerProperty",
0,
"/sensor-id/longinteger_endpoint",
"/sensor_id/longinteger_endpoint",
45543543534,
),
(
"org.astarte-platform.python.e2etest.ServerProperty",
0,
"/sensor-id/stringarray_endpoint",
"/sensor_id/stringarray_endpoint",
["hello", " world"],
),
]
Expand Down

0 comments on commit 191d86f

Please sign in to comment.