mlamina / what-about-jobs

An AI Agent system to figure out how to deal with AI replacing jobs
MIT License
0 stars 0 forks source link

🧪 Add unit tests for Backlog class in test_backlog.py #25

Closed pr-pilot-ai[bot] closed 3 months ago

pr-pilot-ai[bot] commented 3 months ago

I've successfully created unit tests for the Backlog class in the file backlog/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 in backlog/ are not manipulated during testing.

mlamina commented 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

pr-pilot-ai[bot] commented 3 months ago
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

mlamina commented 3 months ago

/pilot look at th

pr-pilot-ai[bot] commented 3 months ago

⌛ I'm on it! Track my progress in the Dashboard. I'll update this comment when I'm done...