Skip to content

Commit

Permalink
feat(core): user can start/end recording actioning by hitting r, acti…
Browse files Browse the repository at this point in the history
…ons will be recorded in `recordings/` directory and the last recording can be replayed by hitting `ctrl+r` - closes #187
  • Loading branch information
sassanh committed Oct 26, 2024
1 parent 87921e9 commit b0cebc7
Show file tree
Hide file tree
Showing 41 changed files with 710 additions and 417 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ scripts/packer/output-*
ubo_app/_version.py

/screenshots
/snapshot.json
/snapshot.bin
/snapshots
/recordings
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- feat(web-ui): add `fields` in `InputDescription` with `InputFieldDescription` data structures to describe the fields of an input demand in detail
- fix(users): avoid setting user as sudoer when it performs a password reset
- feat(ip): use pythonping to perform a real ping test instead to determine the internet connection status instead of opening a socket
- feat(core): user can start/end recording actioning by hitting r, actions will be recorded in `recordings/` directory and the last recording can be replayed by hitting `ctrl+r` - closes #187

## Version 1.0.0

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description = "Ubo main app, running on device initialization. A platform for ru
license = { text = "Apache-2.0" }
readme = "README.md"
requires-python = ">=3.11"
keywords = ['ubo', 'ubo-pod', 'raspberry pi', 'rpi', 'home assistance']
dependencies = [
"psutil >=6.0.0",
"ubo-gui >=0.13.3",
Expand All @@ -22,7 +23,7 @@ dependencies = [
"platformdirs >=4.2.0",
"dill >=0.3.8",
"simpleaudio >=1.0.4",
"python-redux >=0.17.2",
"python-redux >=0.18.2",
"python-debouncer >=0.1.5",
"python-strtobool >=1.0.0",
"python-fake >=0.1.3",
Expand Down Expand Up @@ -146,7 +147,6 @@ cmd = "scripts/deploy.sh"

[tool.ruff]
target-version = 'py311'
extend-exclude = ["setup_scm_schemes.py"]

[tool.ruff.lint]
select = ["ALL"]
Expand Down
18 changes: 9 additions & 9 deletions setup_scm_schemes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from setuptools_scm.version import get_local_node_and_date # pyright: ignore
# ruff: noqa: D100, D103
import re
from datetime import datetime, timezone
from datetime import UTC, datetime

from setuptools_scm.version import ( # pyright: ignore [reportMissingImports]
get_local_node_and_date,
)

def local_scheme(version):
version.node = re.sub(
r'.',
lambda match: str(ord(match.group(0))),
version.node
)

def local_scheme(version) -> str: # noqa: ANN001
version.node = re.sub(r'.', lambda match: str(ord(match.group(0))), version.node)
original_local_version = get_local_node_and_date(version)
numeric_version = original_local_version.replace('+', '').replace('.d', '')
return datetime.now(timezone.utc).strftime('%y%m%d') + numeric_version
return datetime.now(UTC).strftime('%y%m%d') + numeric_version
36 changes: 18 additions & 18 deletions tests/flows/test_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ async def strength() -> int:

from ubo_app.menu_app.menu import MenuApp
from ubo_app.store.core import (
MenuChooseByIconEvent,
MenuChooseByLabelEvent,
MenuGoBackEvent,
MenuChooseByIconAction,
MenuChooseByLabelAction,
MenuGoBackAction,
)
from ubo_app.store.main import store

Expand Down Expand Up @@ -86,52 +86,52 @@ def check_icon(expected_icon: str) -> None:
store_snapshot.take(selector=store_snapshot_selector)

# Select the main menu
store.dispatch(MenuChooseByIconEvent(icon='󰍜'))
store.dispatch(MenuChooseByIconAction(icon='󰍜'))
await stability()

# Select the settings menu
store.dispatch(MenuChooseByLabelEvent(label='Settings'))
store.dispatch(MenuChooseByLabelAction(label='Settings'))
await stability()

# Go to network category
store.dispatch(MenuChooseByLabelEvent(label='Network'))
store.dispatch(MenuChooseByLabelAction(label='Network'))
await stability()

# Open the wireless menu
store.dispatch(MenuChooseByLabelEvent(label='WiFi'))
store.dispatch(MenuChooseByLabelAction(label='WiFi'))
await stability()
window_snapshot.take()

# Select "Select" to open the wireless connection list
store.dispatch(MenuChooseByLabelEvent(label='Select'))
store.dispatch(MenuChooseByLabelAction(label='Select'))
await stability()

# Back to the wireless menu
store.dispatch(MenuGoBackEvent())
store.dispatch(MenuGoBackAction())
await stability()

# Select "Add" to add a new connection
store.dispatch(MenuChooseByLabelEvent(label='Add'))
store.dispatch(MenuChooseByLabelAction(label='Add'))
await stability()
window_snapshot.take()

# Set QR Code image of the WiFi credentials before camera is started
camera.set_image('qrcode/wifi')

# Select "QR code" to scan a QR code for credentials
store.dispatch(MenuChooseByIconEvent(icon='󰄀'))
store.dispatch(MenuChooseByIconAction(icon='󰄀'))

# Success notification should be shown
window_snapshot.take()

# Dismiss the notification informing the user that the connection was added
await check_icon('󰤨')
await wait_for_menu_item(label='', icon='󰆴')
store.dispatch(MenuChooseByIconEvent(icon='󰆴'))
store.dispatch(MenuChooseByIconAction(icon='󰆴'))
await stability()

# Select "Select" to open the wireless connection list and see the new connection
store.dispatch(MenuChooseByLabelEvent(label='Select'))
store.dispatch(MenuChooseByLabelAction(label='Select'))

@wait_for(wait=wait_fixed(1), run_async=True)
def check_connections() -> None:
Expand All @@ -146,28 +146,28 @@ def check_connections() -> None:
window_snapshot.take()

# Select the connection
store.dispatch(MenuChooseByLabelEvent(label='ubo-test-ssid'))
store.dispatch(MenuChooseByLabelAction(label='ubo-test-ssid'))

# Wait for the "Disconnect" item to show up
await wait_for_menu_item(label='Disconnect')
await stability()
window_snapshot.take()
store.dispatch(MenuChooseByLabelEvent(label='Disconnect'))
store.dispatch(MenuChooseByLabelAction(label='Disconnect'))

# Wait for the "Connect" item to show up
await wait_for_menu_item(label='Connect')
await check_icon('󰖪')
await stability()
store_snapshot.take(selector=store_snapshot_selector)
window_snapshot.take()
store.dispatch(MenuChooseByLabelEvent(label='Connect'))
store.dispatch(MenuChooseByLabelAction(label='Connect'))

await wait_for_menu_item(label='Disconnect')
await check_icon('󰤨')
await stability()
store_snapshot.take(selector=store_snapshot_selector)
window_snapshot.take()
store.dispatch(MenuChooseByLabelEvent(label='Delete'))
store.dispatch(MenuChooseByLabelAction(label='Delete'))

@wait_for(wait=wait_fixed(1), run_async=True)
def check_no_connections() -> None:
Expand All @@ -182,7 +182,7 @@ def check_no_connections() -> None:
# Dismiss the notification informing the user that the connection was deleted
await wait_for_menu_item(label='', icon='󰆴')
window_snapshot.take()
store.dispatch(MenuChooseByIconEvent(icon='󰆴'))
store.dispatch(MenuChooseByIconAction(icon='󰆴'))

await wait_for_empty_menu(placeholder='No Wi-Fi connections found')
window_snapshot.take()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": {
"_type": "MainState",
"depth": 1,
"is_recording": false,
"menu": {
"_type": "HeadlessMenu",
"items": [
Expand Down Expand Up @@ -211,11 +212,11 @@
"key": null,
"label": "Already up to date!",
"opacity": null,
"operation": {
"progress": null,
"store_action": {
"_type": "UpdateManagerSetStatusAction",
"status": "checking"
},
"progress": null
}
}
],
"placeholder": null,
Expand Down Expand Up @@ -278,10 +279,10 @@
"key": null,
"label": "Reboot",
"opacity": null,
"operation": {
"progress": null,
"store_action": {
"_type": "RebootAction"
},
"progress": null
}
},
{
"_type": "DispatchItem",
Expand All @@ -298,10 +299,10 @@
"key": null,
"label": "Power off",
"opacity": null,
"operation": {
"progress": null,
"store_action": {
"_type": "PowerOffAction"
},
"progress": null
}
}
],
"placeholder": null,
Expand All @@ -313,6 +314,7 @@
"title": "󰋜test-hostname.local"
},
"path": [],
"recorded_sequence": [],
"settings_items_priorities": {}
},
"status_icons": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": {
"_type": "MainState",
"depth": 1,
"is_recording": false,
"menu": {
"_type": "HeadlessMenu",
"items": [
Expand Down Expand Up @@ -211,11 +212,11 @@
"key": null,
"label": "Already up to date!",
"opacity": null,
"operation": {
"progress": null,
"store_action": {
"_type": "UpdateManagerSetStatusAction",
"status": "checking"
},
"progress": null
}
}
],
"placeholder": null,
Expand Down Expand Up @@ -278,10 +279,10 @@
"key": null,
"label": "Reboot",
"opacity": null,
"operation": {
"progress": null,
"store_action": {
"_type": "RebootAction"
},
"progress": null
}
},
{
"_type": "DispatchItem",
Expand All @@ -298,10 +299,10 @@
"key": null,
"label": "Power off",
"opacity": null,
"operation": {
"progress": null,
"store_action": {
"_type": "PowerOffAction"
},
"progress": null
}
}
],
"placeholder": null,
Expand All @@ -313,6 +314,7 @@
"title": "󰋜test-hostname.local"
},
"path": [],
"recorded_sequence": [],
"settings_items_priorities": {}
},
"status_icons": {
Expand Down
Loading

0 comments on commit b0cebc7

Please sign in to comment.