Skip to content

Commit 6b0a05a

Browse files
committed
Fix test_commands, increment
1 parent 8c861b4 commit 6b0a05a

File tree

3 files changed

+84
-10
lines changed

3 files changed

+84
-10
lines changed

examples/tests/test_scripts/test_commands.py

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
"""
2-
Test: send_command (ring, lock, camera, bluetooth)
2+
Test: Validated command methods (ring, lock, camera, bluetooth, etc.)
33
Usage:
4-
python test_scripts/test_commands.py <command>
4+
python test_scripts/test_commands.py <command> [args...]
5+
6+
Commands:
7+
ring - Make device ring
8+
lock - Lock device screen
9+
camera <front|back> - Take picture (default: back)
10+
bluetooth <on|off> - Toggle Bluetooth
11+
dnd <on|off> - Toggle Do Not Disturb
12+
ringer <normal|vibrate|silent> - Set ringer mode
13+
stats - Get device network statistics
14+
locate [all|gps|cell|last] - Request location update (default: all)
15+
516
Examples:
617
python test_scripts/test_commands.py ring
7-
python test_scripts/test_commands.py "camera front"
8-
python test_scripts/test_commands.py "bluetooth on"
18+
python test_scripts/test_commands.py camera front
19+
python test_scripts/test_commands.py bluetooth on
20+
python test_scripts/test_commands.py ringer vibrate
21+
python test_scripts/test_commands.py locate gps
922
"""
1023
import asyncio
1124
import sys
@@ -18,15 +31,76 @@ async def main():
1831
if not creds.get("BASE_URL") or not creds.get("FMD_ID") or not creds.get("PASSWORD"):
1932
print("Missing credentials.")
2033
return
34+
2135
if len(sys.argv) < 2:
22-
print("Usage: test_commands.py <command>")
36+
print(__doc__)
2337
return
24-
cmd = sys.argv[1]
38+
39+
command = sys.argv[1].lower()
2540
from fmd_api import FmdClient
2641
client = await FmdClient.create(creds["BASE_URL"], creds["FMD_ID"], creds["PASSWORD"])
42+
2743
try:
28-
ok = await client.send_command(cmd)
29-
print(f"Sent '{cmd}': {ok}")
44+
result = False
45+
46+
if command == "ring":
47+
result = await client.send_command("ring")
48+
print(f"Ring command sent: {result}")
49+
50+
elif command == "lock":
51+
result = await client.send_command("lock")
52+
print(f"Lock command sent: {result}")
53+
54+
elif command == "camera":
55+
camera = sys.argv[2].lower() if len(sys.argv) > 2 else "back"
56+
result = await client.take_picture(camera)
57+
print(f"Camera '{camera}' command sent: {result}")
58+
59+
elif command == "bluetooth":
60+
if len(sys.argv) < 3:
61+
print("Error: bluetooth requires on|off argument")
62+
return
63+
state = sys.argv[2].lower()
64+
if state not in ["on", "off"]:
65+
print("Error: bluetooth state must be 'on' or 'off'")
66+
return
67+
result = await client.toggle_bluetooth(state == "on")
68+
print(f"Bluetooth {state} command sent: {result}")
69+
70+
elif command == "dnd":
71+
if len(sys.argv) < 3:
72+
print("Error: dnd requires on|off argument")
73+
return
74+
state = sys.argv[2].lower()
75+
if state not in ["on", "off"]:
76+
print("Error: dnd state must be 'on' or 'off'")
77+
return
78+
result = await client.toggle_do_not_disturb(state == "on")
79+
print(f"Do Not Disturb {state} command sent: {result}")
80+
81+
elif command == "ringer":
82+
if len(sys.argv) < 3:
83+
print("Error: ringer requires normal|vibrate|silent argument")
84+
return
85+
mode = sys.argv[2].lower()
86+
result = await client.set_ringer_mode(mode)
87+
print(f"Ringer mode '{mode}' command sent: {result}")
88+
89+
elif command == "stats":
90+
result = await client.get_device_stats()
91+
print(f"Device stats command sent: {result}")
92+
93+
elif command == "locate":
94+
provider = sys.argv[2].lower() if len(sys.argv) > 2 else "all"
95+
result = await client.request_location(provider)
96+
print(f"Location request ({provider}) sent: {result}")
97+
98+
else:
99+
print(f"Unknown command: {command}")
100+
print(__doc__)
101+
102+
except ValueError as e:
103+
print(f"Error: {e}")
30104
finally:
31105
await client.close()
32106

fmd_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.0-dev3"
1+
__version__ = "2.0.0-dev4"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fmd_api"
3-
version = "2.0.0.dev3"
3+
version = "2.0.0.dev4"
44
authors = [{name = "devinslick"}]
55
description = "A Python client for the FMD (Find My Device) server API"
66
readme = "README.md"

0 commit comments

Comments
 (0)