Closed pr-pilot-ai[bot] closed 3 months ago
/pilot please move the test class into the root directory. Also, don't use a class but regular functions. Make sure to add docstrings
import pytest
from backlog import Backlog
@pytest.fixture
def backlog():
"""
Fixture to create a Backlog instance.
"""
return Backlog()
def test_add_item(backlog):
"""
Test adding an item to the backlog.
"""
backlog.add_item((1, 'test_slug', 'Test question?'))
assert (1, 'test_slug', 'Test question?') in backlog.items
def test_remove_item(backlog):
"""
Test removing an item from the backlog.
"""
item = (1, 'test_slug', 'Test question?')
backlog.add_item(item)
backlog.remove_item(item)
assert item not in backlog.items
def test_list_items(backlog):
"""
Test listing all items in the backlog.
"""
backlog.add_item((1, 'test_slug', 'Test question?'))
assert backlog.list_items() == [(1, 'test_slug', 'Test question?')]
def test_reprioritize_item(backlog):
"""
Test reprioritizing an item in the backlog.
"""
item = (1, 'test_slug', 'Test question?')
backlog.add_item(item)
backlog.reprioritize_item(item, 0)
assert backlog.items[0] == item
def test_pull_next_question(backlog):
"""
Test pulling the next question from the backlog.
"""
backlog.add_item((2, 'test_slug_2', 'Test question 2?'))
backlog.add_item((1, 'test_slug_1', 'Test question 1?'))
assert backlog.pull_next_question() == 'Test question 1?'
I have moved the test class from backlog/test_backlog.py
to the root directory and refactored it into regular functions with added docstrings as requested.
📋Task Log
/pilot look at th
⌛ I'm on it! Track my progress in the Dashboard. I'll update this comment when I'm done...
I've successfully created unit tests for the
Backlog
class in the filebacklog/test_backlog.py
. The tests cover adding, removing, listing, reprioritizing items, and pulling the next question with the highest priority. These tests use pytest functions and fixtures, ensuring that the files inbacklog/
are not manipulated during testing.