sbs/test/test_card.py
Steve Milner c2a37b748d test: Add tests for ds
Assisted-by: Gemini Flash 2.5 Flash
2025-08-14 15:01:42 -04:00

95 lines
2.6 KiB
Python

# This file is part of sbs
#
# Copyright (C) 2025 Steve Milner
#
# SPDX-License-Identifier: GPL-3.0-or-later
# Generated by Gemini 2.5 Flash
import pytest
from sbs.ds.card import Card
def test_card_initialization():
"""
Test that the Card object initializes correctly with all provided attributes.
"""
card = Card(
key="PROJ-123",
assignee="John Doe",
summary="Implement login feature",
description="User should be able to log in with username and password.",
story_points=5,
)
assert card.key == "PROJ-123"
assert card.assignee == "John Doe"
assert card.summary == "Implement login feature"
assert (
card.description == "User should be able to log in with username and password."
)
assert card.story_points == 5
def test_card_repr_method():
"""
Test the __repr__ method to ensure it returns the expected string format.
"""
card = Card(
key="PROJ-456",
assignee="Jane Smith",
summary="Fix bug on dashboard",
description="Dashboard not displaying correct data.",
story_points=3,
)
expected_repr = """Key: PROJ-456
Assignee: Jane Smith
Story Points: 3
Summary: Fix bug on dashboard
Description: Dashboard not displaying correct data."""
assert repr(card) == expected_repr
def test_card_attributes_can_be_accessed():
"""
Test that individual attributes of the Card object can be accessed after initialization.
"""
card = Card(
key="TASK-001",
assignee="Alice Brown",
summary="Refactor old code",
description="Clean up deprecated functions in module X.",
story_points=8,
)
assert card.key == "TASK-001"
assert card.assignee == "Alice Brown"
assert card.summary == "Refactor old code"
assert card.description == "Clean up deprecated functions in module X."
assert card.story_points == 8
def test_card_story_points_zero():
"""
Test initialization with zero story points.
"""
card = Card(
key="BUG-007",
assignee="Bob White",
summary="Minor text typo",
description="Fix typo on homepage footer.",
story_points=0,
)
assert card.story_points == 0
def test_card_empty_strings():
"""
Test initialization with empty strings for key, assignee, summary, and description.
"""
card = Card(key="", assignee="", summary="", description="", story_points=1)
assert card.key == ""
assert card.assignee == ""
assert card.summary == ""
assert card.description == ""
assert card.story_points == 1