File size: 2,132 Bytes
685f223 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | """
Tests for LearningNode model.
Following TDD principles - RED phase.
"""
import pytest
from src.models.learning_node import LearningNode, NodeType
class TestLearningNode:
"""Test cases for LearningNode class."""
def test_create_valid_learning_node(self):
"""Test creating a valid learning node."""
# RED: This test should pass after implementation
node = LearningNode(
id="llm-apis",
title="LLM APIs",
description="Understanding different types of LLMs and their APIs",
node_type=NodeType.TOPIC,
subtopics=["Types of LLMs", "Structured Outputs", "Prompt Caching", "Multi-modal models"],
prerequisites=["basic-programming"],
estimated_hours=20,
resources=["https://example.com/llm-guide"]
)
assert node.id == "llm-apis"
assert node.title == "LLM APIs"
assert node.node_type == NodeType.TOPIC
assert len(node.subtopics) == 4
assert node.estimated_hours == 20
def test_empty_id_raises_error(self):
"""Test that empty ID raises ValueError."""
# RED: This test should fail initially
with pytest.raises(ValueError, match="Node ID cannot be empty"):
LearningNode(
id="",
title="Test Node",
description="Test description",
node_type=NodeType.TOPIC,
subtopics=[],
prerequisites=[],
estimated_hours=10,
resources=[]
)
def test_empty_title_raises_error(self):
"""Test that empty title raises ValueError."""
# RED: This test should fail initially
with pytest.raises(ValueError, match="Node title cannot be empty"):
LearningNode(
id="test-id",
title="",
description="Test description",
node_type=NodeType.TOPIC,
subtopics=[],
prerequisites=[],
estimated_hours=10,
resources=[]
)
|