|
4 | 4 | get_connection_feature, |
5 | 5 | supports_feature, |
6 | 6 | get_server_features, |
| 7 | + get_cli_feature_flag_registry, |
7 | 8 | SERVER_FEATURE_FLAGS, |
| 9 | + _parse_feature_flag_value, |
| 10 | + _parse_cli_feature_flags, |
8 | 11 | ) |
9 | 12 |
|
10 | 13 |
|
@@ -96,3 +99,48 @@ def test_empty_feature_flags_dict(self): |
96 | 99 | result = get_connection_feature(sockets_metadata, "sid1", "any_feature") |
97 | 100 | assert result is False |
98 | 101 | assert supports_feature(sockets_metadata, "sid1", "any_feature") is False |
| 102 | + |
| 103 | + |
| 104 | +class TestParseFeatureFlagValue: |
| 105 | + """Test suite for _parse_feature_flag_value.""" |
| 106 | + |
| 107 | + def test_true_string(self): |
| 108 | + assert _parse_feature_flag_value("true") is True |
| 109 | + assert _parse_feature_flag_value("True") is True |
| 110 | + assert _parse_feature_flag_value("TRUE") is True |
| 111 | + |
| 112 | + def test_false_string(self): |
| 113 | + assert _parse_feature_flag_value("false") is False |
| 114 | + assert _parse_feature_flag_value("False") is False |
| 115 | + |
| 116 | + def test_plain_string(self): |
| 117 | + assert _parse_feature_flag_value("hello") == "hello" |
| 118 | + assert _parse_feature_flag_value("") == "" |
| 119 | + |
| 120 | + def test_numeric_stays_string(self): |
| 121 | + assert _parse_feature_flag_value("42") == "42" |
| 122 | + assert _parse_feature_flag_value("3.14") == "3.14" |
| 123 | + |
| 124 | + |
| 125 | +class TestParseCliFeatureFlags: |
| 126 | + """Test suite for _parse_cli_feature_flags.""" |
| 127 | + |
| 128 | + def test_single_flag(self, monkeypatch): |
| 129 | + monkeypatch.setattr("comfy_api.feature_flags.args", type("Args", (), {"feature_flag": ["key=true"]})()) |
| 130 | + result = _parse_cli_feature_flags() |
| 131 | + assert result == {"key": True} |
| 132 | + |
| 133 | + def test_missing_equals_skipped(self, monkeypatch): |
| 134 | + monkeypatch.setattr("comfy_api.feature_flags.args", type("Args", (), {"feature_flag": ["noequals", "valid=1"]})()) |
| 135 | + result = _parse_cli_feature_flags() |
| 136 | + assert result == {"valid": "1"} |
| 137 | + |
| 138 | + |
| 139 | +class TestCliFeatureFlagRegistry: |
| 140 | + """Test suite for the CLI feature flag registry.""" |
| 141 | + |
| 142 | + def test_registry_entries_have_required_fields(self): |
| 143 | + for key, info in get_cli_feature_flag_registry().items(): |
| 144 | + assert "type" in info, f"{key} missing 'type'" |
| 145 | + assert "default" in info, f"{key} missing 'default'" |
| 146 | + assert "description" in info, f"{key} missing 'description'" |
0 commit comments