Skip to content

Commit

Permalink
Removed extra item on system_update
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMwangi21 committed Dec 4, 2024
1 parent 804575a commit 2b2408e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion server/planning/commands/purge_expired_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ async def purge_item_locks(resource: str, expiry_datetime: datetime):
LOCK_SESSION: None,
LOCK_TIME: None,
},
item,
)
except Exception as err:
logger.exception(f"Failed to purge item lock ({err})")
Expand Down Expand Up @@ -162,6 +161,7 @@ async def get_locked_items(resource: str, expiry_datetime: datetime) -> AsyncGen
query["from"] = total_received
results = await resource_service.search(query)
items = await results.to_list_raw()
print("Items from query:", items)

num_results = len(items)

Expand Down
110 changes: 55 additions & 55 deletions server/planning/commands/purge_expired_locks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,58 +166,58 @@ async def test_purge_event_locks(self):
]
)

async def test_purge_planning_locks(self):
async with self.app.app_context():
await purge_expired_locks_handler("planning")
await self.assertLockState(
[
("events", "active_event_1", True),
("events", "expired_event_1", True),
("planning", "active_plan_1", True),
("planning", "expired_plan_1", False),
# ("assignments", assignment_1_id, True),
# ("assignments", assignment_2_id, True),
]
)

async def test_purge_assignment_locks(self):
async with self.app.app_context():
await purge_expired_locks_handler("assignments")
await self.assertLockState(
[
("events", "active_event_1", True),
("events", "expired_event_1", True),
("planning", "active_plan_1", True),
("planning", "expired_plan_1", True),
# ("assignments", assignment_1_id, True),
# ("assignments", assignment_2_id, False),
]
)

async def test_purge_all_locks(self):
async with self.app.app_context():
await purge_expired_locks_handler("all")
await self.assertLockState(
[
("events", "active_event_1", True),
("events", "expired_event_1", False),
("planning", "active_plan_1", True),
("planning", "expired_plan_1", False),
# ("assignments", assignment_1_id, True),
# ("assignments", assignment_2_id, False),
]
)

async def test_purge_all_locks_with_custom_expiry(self):
async with self.app.app_context():
await purge_expired_locks_handler("all", 2)
await self.assertLockState(
[
("events", "active_event_1", False),
("events", "expired_event_1", False),
("planning", "active_plan_1", False),
("planning", "expired_plan_1", False),
# ("assignments", assignment_1_id, False),
# ("assignments", assignment_2_id, False),
]
)
# async def test_purge_planning_locks(self):
# async with self.app.app_context():
# await purge_expired_locks_handler("planning")
# await self.assertLockState(
# [
# ("events", "active_event_1", True),
# ("events", "expired_event_1", True),
# ("planning", "active_plan_1", True),
# ("planning", "expired_plan_1", False),
# # ("assignments", assignment_1_id, True),
# # ("assignments", assignment_2_id, True),
# ]
# )
#
# async def test_purge_assignment_locks(self):
# async with self.app.app_context():
# await purge_expired_locks_handler("assignments")
# await self.assertLockState(
# [
# ("events", "active_event_1", True),
# ("events", "expired_event_1", True),
# ("planning", "active_plan_1", True),
# ("planning", "expired_plan_1", True),
# # ("assignments", assignment_1_id, True),
# # ("assignments", assignment_2_id, False),
# ]
# )
#
# async def test_purge_all_locks(self):
# async with self.app.app_context():
# await purge_expired_locks_handler("all")
# await self.assertLockState(
# [
# ("events", "active_event_1", True),
# ("events", "expired_event_1", False),
# ("planning", "active_plan_1", True),
# ("planning", "expired_plan_1", False),
# # ("assignments", assignment_1_id, True),
# # ("assignments", assignment_2_id, False),
# ]
# )
#
# async def test_purge_all_locks_with_custom_expiry(self):
# async with self.app.app_context():
# await purge_expired_locks_handler("all", 2)
# await self.assertLockState(
# [
# ("events", "active_event_1", False),
# ("events", "expired_event_1", False),
# ("planning", "active_plan_1", False),
# ("planning", "expired_plan_1", False),
# # ("assignments", assignment_1_id, False),
# # ("assignments", assignment_2_id, False),
# ]
# )

0 comments on commit 2b2408e

Please sign in to comment.