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:** **Start the alarm immediately:**
```graphql ```graphql
mutation { mutation {
startWecker startRinging
} }
``` ```
Returns `true` if the alarm started, `false` if it was already ringing (ignored). 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:** **Stop the alarm immediately:**
```graphql ```graphql
mutation { mutation {
stopWecker stopRinging
} }
``` ```
Returns `true` if the alarm was stopped, `false` if it wasn't ringing. 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 return False
@strawberry.field @strawberry.field
def start_wecker(self) -> bool: def start_ringing(self) -> bool:
"""Start the wecker alarm if it is not already ringing. """Start the wecker alarm if it is not already ringing.
Returns True if started, False if already ringing.""" Returns True if started, False if already ringing."""
if is_wecker_ringing(): if is_wecker_ringing():
@@ -110,7 +110,7 @@ class Mutation:
return True return True
@strawberry.field @strawberry.field
def stop_wecker(self) -> bool: def stop_ringing(self) -> bool:
"""Stop the wecker alarm if it is currently ringing. """Stop the wecker alarm if it is currently ringing.
Returns True if stopped, False if not ringing.""" Returns True if stopped, False if not ringing."""
if not is_wecker_ringing(): if not is_wecker_ringing():
+21 -22
View File
@@ -203,8 +203,8 @@ def test_graphql_workflow():
assert res.json()["data"]["getAlarms"] == [] assert res.json()["data"]["getAlarms"] == []
def test_start_wecker_starts_process_when_not_ringing(): def test_start_ringing_starts_process_when_not_ringing():
"""startWecker returns True and spawns wecker.py when not already ringing.""" """startRinging returns True and spawns wecker.py when not already ringing."""
from api.schema import Mutation from api.schema import Mutation
mutation = Mutation() mutation = Mutation()
@@ -213,30 +213,29 @@ def test_start_wecker_starts_process_when_not_ringing():
patch("subprocess.Popen") as mock_popen: patch("subprocess.Popen") as mock_popen:
mock_proc = mock_popen.return_value mock_proc = mock_popen.return_value
mock_proc.pid = 9999 mock_proc.pid = 9999
result = mutation.start_wecker() result = mutation.start_ringing()
assert result is True assert result is True
mock_popen.assert_called_once() mock_popen.assert_called_once()
# Verify the command contains wecker.py
args, kwargs = mock_popen.call_args args, kwargs = mock_popen.call_args
assert "wecker.py" in args[0] assert "wecker.py" in args[0]
assert kwargs.get("shell") is True assert kwargs.get("shell") is True
def test_start_wecker_ignores_when_already_ringing(): def test_start_ringing_ignores_when_already_ringing():
"""startWecker returns False when wecker is already ringing.""" """startRinging returns False when already ringing."""
from api.schema import Mutation from api.schema import Mutation
mutation = Mutation() mutation = Mutation()
with patch("api.schema.is_wecker_ringing", return_value=True), \ with patch("api.schema.is_wecker_ringing", return_value=True), \
patch("api.schema.subprocess.Popen") as mock_popen: patch("subprocess.Popen") as mock_popen:
result = mutation.start_wecker() result = mutation.start_ringing()
assert result is False assert result is False
mock_popen.assert_not_called() mock_popen.assert_not_called()
def test_stop_wecker_kills_process_when_ringing(): def test_stop_ringing_kills_process_when_ringing():
"""stopWecker returns True and kills the process wecker is ringing.""" """stopRinging returns True and kills the process when ringing."""
from api.schema import Mutation from api.schema import Mutation
mutation = 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 = mock_open.return_value.__enter__.return_value
mock_f.read.return_value = "1234" mock_f.read.return_value = "1234"
mock_kill.return_value = None mock_kill.return_value = None
result = mutation.stop_wecker() result = mutation.stop_ringing()
assert result is True assert result is True
mock_kill.assert_called_with(1234, 15) mock_kill.assert_called_with(1234, 15)
def test_stop_wecker_does_nothing_when_not_ringing(): def test_stop_ringing_does_nothing_when_not_ringing():
"""stopWecker returns False when wecker is not ringing.""" """stopRinging returns False when not ringing."""
from api.schema import Mutation from api.schema import Mutation
mutation = Mutation() mutation = Mutation()
with patch("api.schema.is_wecker_ringing", return_value=False), \ with patch("api.schema.is_wecker_ringing", return_value=False), \
patch("api.schema.os.kill") as mock_kill: patch("api.schema.os.kill") as mock_kill:
result = mutation.stop_wecker() result = mutation.stop_ringing()
assert result is False assert result is False
mock_kill.assert_not_called() mock_kill.assert_not_called()
def test_start_wecker_graphql_endpoint(): def test_start_ringing_graphql_endpoint():
"""GraphQL mutation startWecker works via the API.""" """GraphQL mutation startRinging works via the API."""
headers = {"X-API-Key": "test-secret"} headers = {"X-API-Key": "test-secret"}
mutation_str = """ mutation_str = """
mutation { mutation {
startWecker startRinging
} }
""" """
@@ -281,15 +280,15 @@ def test_start_wecker_graphql_endpoint():
mock_proc.pid = 9999 mock_proc.pid = 9999
res = client.post("/graphql", json={"query": mutation_str}, headers=headers) res = client.post("/graphql", json={"query": mutation_str}, headers=headers)
assert res.status_code == 200 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(): def test_stop_ringing_graphql_endpoint():
"""GraphQL mutation stopWecker works via the API.""" """GraphQL mutation stopRinging works via the API."""
headers = {"X-API-Key": "test-secret"} headers = {"X-API-Key": "test-secret"}
mutation_str = """ mutation_str = """
mutation { mutation {
stopWecker stopRinging
} }
""" """
@@ -301,7 +300,7 @@ def test_stop_wecker_graphql_endpoint():
mock_kill.return_value = None mock_kill.return_value = None
res = client.post("/graphql", json={"query": mutation_str}, headers=headers) res = client.post("/graphql", json={"query": mutation_str}, headers=headers)
assert res.status_code == 200 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(): def test_pid_file_same_shared_constant_in_api():