refactor: rename startWecker/stopWecker mutations to startRinging/stopRinging

'Wecker' is a Swiss-German term with no meaning in English.
Renaming to startRinging/stopRinging for better clarity.
This commit is contained in:
Markus Graf
2026-05-19 15:28:44 +02:00
parent df7bec1054
commit 41d8ffc404
3 changed files with 25 additions and 26 deletions
+2 -2
View File
@@ -102,7 +102,7 @@ mutation {
**Start the alarm immediately:**
```graphql
mutation {
startWecker
startRinging
}
```
Returns `true` if the alarm started, `false` if it was already ringing (ignored).
@@ -110,7 +110,7 @@ Returns `true` if the alarm started, `false` if it was already ringing (ignored)
**Stop the alarm immediately:**
```graphql
mutation {
stopWecker
stopRinging
}
```
Returns `true` if the alarm was stopped, `false` if it wasn't ringing.
+2 -2
View File
@@ -98,7 +98,7 @@ class Mutation:
return False
@strawberry.field
def start_wecker(self) -> bool:
def start_ringing(self) -> bool:
"""Start the wecker alarm if it is not already ringing.
Returns True if started, False if already ringing."""
if is_wecker_ringing():
@@ -110,7 +110,7 @@ class Mutation:
return True
@strawberry.field
def stop_wecker(self) -> bool:
def stop_ringing(self) -> bool:
"""Stop the wecker alarm if it is currently ringing.
Returns True if stopped, False if not ringing."""
if not is_wecker_ringing():
+21 -22
View File
@@ -203,8 +203,8 @@ def test_graphql_workflow():
assert res.json()["data"]["getAlarms"] == []
def test_start_wecker_starts_process_when_not_ringing():
"""startWecker returns True and spawns wecker.py when not already ringing."""
def test_start_ringing_starts_process_when_not_ringing():
"""startRinging returns True and spawns wecker.py when not already ringing."""
from api.schema import Mutation
mutation = Mutation()
@@ -213,30 +213,29 @@ def test_start_wecker_starts_process_when_not_ringing():
patch("subprocess.Popen") as mock_popen:
mock_proc = mock_popen.return_value
mock_proc.pid = 9999
result = mutation.start_wecker()
result = mutation.start_ringing()
assert result is True
mock_popen.assert_called_once()
# Verify the command contains wecker.py
args, kwargs = mock_popen.call_args
assert "wecker.py" in args[0]
assert kwargs.get("shell") is True
def test_start_wecker_ignores_when_already_ringing():
"""startWecker returns False when wecker is already ringing."""
def test_start_ringing_ignores_when_already_ringing():
"""startRinging returns False when already ringing."""
from api.schema import Mutation
mutation = Mutation()
with patch("api.schema.is_wecker_ringing", return_value=True), \
patch("api.schema.subprocess.Popen") as mock_popen:
result = mutation.start_wecker()
patch("subprocess.Popen") as mock_popen:
result = mutation.start_ringing()
assert result is False
mock_popen.assert_not_called()
def test_stop_wecker_kills_process_when_ringing():
"""stopWecker returns True and kills the process wecker is ringing."""
def test_stop_ringing_kills_process_when_ringing():
"""stopRinging returns True and kills the process when ringing."""
from api.schema import Mutation
mutation = Mutation()
@@ -248,30 +247,30 @@ def test_stop_wecker_kills_process_when_ringing():
mock_f = mock_open.return_value.__enter__.return_value
mock_f.read.return_value = "1234"
mock_kill.return_value = None
result = mutation.stop_wecker()
result = mutation.stop_ringing()
assert result is True
mock_kill.assert_called_with(1234, 15)
def test_stop_wecker_does_nothing_when_not_ringing():
"""stopWecker returns False when wecker is not ringing."""
def test_stop_ringing_does_nothing_when_not_ringing():
"""stopRinging returns False when not ringing."""
from api.schema import Mutation
mutation = Mutation()
with patch("api.schema.is_wecker_ringing", return_value=False), \
patch("api.schema.os.kill") as mock_kill:
result = mutation.stop_wecker()
result = mutation.stop_ringing()
assert result is False
mock_kill.assert_not_called()
def test_start_wecker_graphql_endpoint():
"""GraphQL mutation startWecker works via the API."""
def test_start_ringing_graphql_endpoint():
"""GraphQL mutation startRinging works via the API."""
headers = {"X-API-Key": "test-secret"}
mutation_str = """
mutation {
startWecker
startRinging
}
"""
@@ -281,15 +280,15 @@ def test_start_wecker_graphql_endpoint():
mock_proc.pid = 9999
res = client.post("/graphql", json={"query": mutation_str}, headers=headers)
assert res.status_code == 200
assert res.json()["data"]["startWecker"] is True
assert res.json()["data"]["startRinging"] is True
def test_stop_wecker_graphql_endpoint():
"""GraphQL mutation stopWecker works via the API."""
def test_stop_ringing_graphql_endpoint():
"""GraphQL mutation stopRinging works via the API."""
headers = {"X-API-Key": "test-secret"}
mutation_str = """
mutation {
stopWecker
stopRinging
}
"""
@@ -301,7 +300,7 @@ def test_stop_wecker_graphql_endpoint():
mock_kill.return_value = None
res = client.post("/graphql", json={"query": mutation_str}, headers=headers)
assert res.status_code == 200
assert res.json()["data"]["stopWecker"] is True
assert res.json()["data"]["stopRinging"] is True
def test_pid_file_same_shared_constant_in_api():