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.task_api import task_api
|
||||
from api.auth_api import auth_api
|
||||
from db.db import task_db, child_db, users_db
|
||||
from db.db import task_db, child_db, users_db, pending_confirmations_db
|
||||
from tinydb import Query
|
||||
from models.pending_confirmation import PendingConfirmation
|
||||
import jwt
|
||||
|
||||
|
||||
@@ -146,4 +147,59 @@ def test_delete_assigned_task_removes_from_child(client):
|
||||
assert resp.status_code == 200
|
||||
# verify the task id is no longer in the child's tasks
|
||||
child = child_db.search(ChildQuery.id == 'child_for_task_delete')[0]
|
||||
assert 't_delete_assigned' not in child.get('tasks', [])
|
||||
assert 't_delete_assigned' not in child.get('tasks', [])
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Bug #10: Editing task points/type resets pending confirmations
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_edit_task_points_resets_pending_confirmations(client):
|
||||
"""Changing a task's points should remove all pending chore confirmations for that task."""
|
||||
task_db.truncate()
|
||||
child_db.truncate()
|
||||
pending_confirmations_db.truncate()
|
||||
|
||||
task_db.insert({'id': 't_pending', 'name': 'Sweep', 'points': 5, 'type': 'chore', 'user_id': 'testuserid'})
|
||||
child_db.insert({
|
||||
'id': 'c1', 'name': 'Alice', 'age': 8, 'points': 0,
|
||||
'tasks': ['t_pending'], 'rewards': [], 'user_id': 'testuserid'
|
||||
})
|
||||
pending_confirmations_db.insert(PendingConfirmation(
|
||||
child_id='c1', entity_id='t_pending', entity_type='chore', user_id='testuserid'
|
||||
).to_dict())
|
||||
|
||||
resp = client.put('/task/t_pending/edit', json={'points': 10})
|
||||
assert resp.status_code == 200
|
||||
|
||||
PQ = Query()
|
||||
conf = pending_confirmations_db.get(
|
||||
(PQ.child_id == 'c1') & (PQ.entity_id == 't_pending') & (PQ.entity_type == 'chore')
|
||||
)
|
||||
assert conf is None
|
||||
|
||||
|
||||
def test_edit_task_name_only_keeps_pending(client):
|
||||
"""Changing only the task name should not reset pending confirmations."""
|
||||
task_db.truncate()
|
||||
child_db.truncate()
|
||||
pending_confirmations_db.truncate()
|
||||
|
||||
task_db.insert({'id': 't_name', 'name': 'Old Name', 'points': 5, 'type': 'chore', 'user_id': 'testuserid'})
|
||||
child_db.insert({
|
||||
'id': 'c2', 'name': 'Bob', 'age': 7, 'points': 0,
|
||||
'tasks': ['t_name'], 'rewards': [], 'user_id': 'testuserid'
|
||||
})
|
||||
pending_confirmations_db.insert(PendingConfirmation(
|
||||
child_id='c2', entity_id='t_name', entity_type='chore', user_id='testuserid'
|
||||
).to_dict())
|
||||
|
||||
resp = client.put('/task/t_name/edit', json={'name': 'New Name'})
|
||||
assert resp.status_code == 200
|
||||
|
||||
PQ = Query()
|
||||
conf = pending_confirmations_db.get(
|
||||
(PQ.child_id == 'c2') & (PQ.entity_id == 't_name') & (PQ.entity_type == 'chore')
|
||||
)
|
||||
assert conf is not None
|
||||
assert conf['status'] == 'pending'
|
||||
Reference in New Issue
Block a user