Skip to content

Commit

Permalink
return task id after adding
Browse files Browse the repository at this point in the history
  • Loading branch information
thecarrot123 committed Apr 29, 2024
1 parent dca0448 commit 19a066b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def add_task(update: Update, context: CallbackContext):
name=str(task_id),
)

await update.message.reply_text("Task added successfully!")
await update.message.reply_text(f"Task {task_id} added successfully!")
except sqlite3.Error as e:
logging.error(f"Database error: {e}")
await update.message.reply_text(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_add_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ async def test_add_task_valid_input():
with patch("sqlite3.connect") as mock_connect:
mock_cursor = MagicMock()
mock_connect.return_value.cursor.return_value = mock_cursor
task_id = mock_cursor.lastrowid

await add_task(update, context)

mock_cursor.execute.assert_called()
update.message.reply_text.assert_called_with(
"Task added successfully!"
f"Task {task_id} added successfully!"
)


Expand Down

0 comments on commit 19a066b

Please sign in to comment.