added fixes for bug plan 1.0.6RC01
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 5m43s
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 5m43s
This commit is contained in:
@@ -6,8 +6,9 @@ from werkzeug.security import generate_password_hash
|
||||
from flask import Flask
|
||||
from api.chore_schedule_api import chore_schedule_api
|
||||
from api.auth_api import auth_api
|
||||
from db.db import users_db, child_db, chore_schedules_db, task_extensions_db
|
||||
from db.db import users_db, child_db, chore_schedules_db, task_extensions_db, pending_confirmations_db, task_db
|
||||
from tinydb import Query
|
||||
from models.pending_confirmation import PendingConfirmation
|
||||
|
||||
|
||||
TEST_EMAIL = "sched_test@example.com"
|
||||
@@ -412,3 +413,36 @@ def test_chore_schedule_to_dict_includes_enabled():
|
||||
d = s.to_dict()
|
||||
assert "enabled" in d
|
||||
assert d["enabled"] is False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Bug #10: Setting schedule resets pending confirmations
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_set_schedule_resets_pending_confirmation(client):
|
||||
"""Setting/updating a chore schedule should remove pending chore confirmations."""
|
||||
chore_schedules_db.truncate()
|
||||
pending_confirmations_db.truncate()
|
||||
task_db.truncate()
|
||||
|
||||
task_db.insert({
|
||||
'id': TEST_TASK_ID, 'name': 'Test Chore', 'points': 5,
|
||||
'type': 'chore', 'user_id': TEST_USER_ID
|
||||
})
|
||||
pending_confirmations_db.insert(PendingConfirmation(
|
||||
child_id=TEST_CHILD_ID, entity_id=TEST_TASK_ID,
|
||||
entity_type='chore', user_id=TEST_USER_ID
|
||||
).to_dict())
|
||||
|
||||
payload = {
|
||||
"mode": "days",
|
||||
"day_configs": [{"day": 1, "hour": 8, "minute": 0}],
|
||||
}
|
||||
resp = client.put(f'/child/{TEST_CHILD_ID}/task/{TEST_TASK_ID}/schedule', json=payload)
|
||||
assert resp.status_code == 200
|
||||
|
||||
PQ = Query()
|
||||
conf = pending_confirmations_db.get(
|
||||
(PQ.child_id == TEST_CHILD_ID) & (PQ.entity_id == TEST_TASK_ID) & (PQ.entity_type == 'chore')
|
||||
)
|
||||
assert conf is None
|
||||
|
||||
Reference in New Issue
Block a user