File size: 3,828 Bytes
2888065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f606cc0
2888065
 
 
 
 
 
 
e660ef7
2888065
 
 
e660ef7
 
2888065
 
 
e660ef7
2888065
 
 
 
8f354fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2d6335
 
e43a92b
 
 
 
 
 
 
 
 
 
a2d6335
 
 
 
964b35b
 
 
a2d6335
 
 
964b35b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""Tests for config/settings.py."""
from pathlib import Path


class TestSettings:
    def test_loads_config_yaml(self):
        from config.settings import settings
        assert settings.agents
        assert "design" in settings.agents

    def test_output_dir_property(self):
        from config.settings import settings
        assert isinstance(settings.output_dir, Path)

    def test_web_port_property(self):
        from config.settings import settings
        assert isinstance(settings.web_port, int)
        assert settings.web_port > 0

    def test_model_for_property(self):
        from config.settings import settings
        models = settings.model_for
        assert "anthropic" in models
        assert "openai" in models
        assert "gemini" in models

    def test_max_tokens_property(self):
        from config.settings import settings
        assert settings.max_tokens == 8192

    def test_temperature_property(self):
        from config.settings import settings
        assert settings.temperature == 0.2

    def test_validation_config(self):
        from config.settings import settings
        assert settings.validation.min_wall_thickness_mm == 1.5

    def test_routing_keywords_loaded(self):
        from config.settings import settings
        assert "design" in settings.routing.keywords
        assert "engineering" in settings.routing.keywords

    def test_fasteners_loaded(self):
        from config.settings import settings
        assert settings.fasteners["M6"] == 6.6  # fasteners is a flat dict — bracket access is correct

    def test_materials_loaded(self):
        from config.settings import settings
        assert "aluminum" in settings.materials


class TestPlanningConfig:
    def test_planning_defaults(self):
        from config.settings import Settings
        s = Settings()
        assert s.planning.threshold == 8.0
        assert s.planning.weights["material"] == 3
        assert s.planning.caps["dimension"] == 4
        assert "plan" in s.planning.trigger_keywords
        assert "cad" in s.planning.approved_agents

    def test_planning_threshold_from_yaml(self):
        from config.settings import settings
        assert settings.planning.threshold == 8.0


def test_planning_field_agents_defaults():
    from config.settings import PlanningConfig
    cfg = PlanningConfig()
    assert cfg.field_agents["material"] == "engineering"
    assert cfg.field_agents["features"] == "design"
    assert cfg.field_agents["constraints"] == "cnc"
    assert cfg.field_agents["axis_recommendation"] == "cnc"
    assert cfg.field_agents["part_name"] == "design"


class TestGapAnalysisConfig:
    def test_gap_analysis_defaults(self):
        from config.settings import Settings
        s = Settings()
        assert s.gap_analysis.model == "gemini/gemini-2.5-flash"
        assert s.gap_analysis.temperature == 0.1
        assert s.gap_analysis.max_tokens == 2048

    def test_gap_analysis_loaded_from_yaml(self):
        from config.settings import settings
        assert settings.gap_analysis.model == "gemini/gemini-2.5-flash"
        assert settings.gap_analysis.temperature == 0.1
        assert settings.gap_analysis.max_tokens == 2048


def test_gap_analysis_config_has_model_field():
    """New GapAnalysisConfig should have model, temperature, max_tokens."""
    from config.settings import GapAnalysisConfig
    cfg = GapAnalysisConfig()
    assert cfg.model == "gemini/gemini-2.5-flash"
    assert cfg.temperature == 0.1
    assert cfg.max_tokens == 2048


def test_gap_analysis_config_no_keyword_fields():
    """Old category_keywords and category_agents should not exist."""
    from config.settings import GapAnalysisConfig
    cfg = GapAnalysisConfig()
    assert not hasattr(cfg, "category_keywords")
    assert not hasattr(cfg, "category_agents")