File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Tests for Settings field validators."""
2+
3+ import pytest
4+ from pydantic import ValidationError
5+
6+ from token0 .config import Settings
7+
8+
9+ def test_storage_mode_valid_values ():
10+ assert Settings (storage_mode = "lite" ).storage_mode == "lite"
11+ assert Settings (storage_mode = "full" ).storage_mode == "full"
12+
13+
14+ def test_storage_mode_invalid_raises ():
15+ with pytest .raises (ValidationError ):
16+ Settings (storage_mode = "prod" )
17+
18+
19+ def test_text_density_threshold_valid ():
20+ assert Settings (text_density_threshold = 0.0 ).text_density_threshold == 0.0
21+ assert Settings (text_density_threshold = 1.0 ).text_density_threshold == 1.0
22+ assert Settings (text_density_threshold = 0.52 ).text_density_threshold == 0.52
23+
24+
25+ def test_text_density_threshold_out_of_range_raises ():
26+ with pytest .raises (ValidationError ):
27+ Settings (text_density_threshold = 1.1 )
28+ with pytest .raises (ValidationError ):
29+ Settings (text_density_threshold = - 0.1 )
30+
31+
32+ def test_port_valid ():
33+ assert Settings (port = 8000 ).port == 8000
34+ assert Settings (port = 1 ).port == 1
35+ assert Settings (port = 65535 ).port == 65535
36+
37+
38+ def test_port_out_of_range_raises ():
39+ with pytest .raises (ValidationError ):
40+ Settings (port = 0 )
41+ with pytest .raises (ValidationError ):
42+ Settings (port = 65536 )
You can’t perform that action at this time.
0 commit comments