1+ #
2+ # Copyright (c) nexB Inc. and others. All rights reserved.
3+ # VulnerableCode is a trademark of nexB Inc.
4+ # SPDX-License-Identifier: Apache-2.0
5+ # See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+ # See https://github.com/aboutcode-org/vulnerablecode for support or download.
7+ # See https://aboutcode.org for more information about nexB OSS projects.
8+ #
9+
10+ from vulnerabilities .templatetags .ssvc_filters import to_yaml
11+
12+
13+ def test_to_yaml_with_ssvc_options ():
14+ options = [
15+ {"Exploitation" : "active" },
16+ {"Automatable" : "yes" },
17+ {"Technical Impact" : "total" },
18+ {"Mission Prevalence" : "essential" },
19+ {"Public Well-being Impact" : "irreversible" },
20+ {"Mission & Well-being" : "high" },
21+ ]
22+ result = to_yaml (options )
23+ assert "Exploitation: active" in result
24+ assert "Technical Impact: total" in result
25+ assert "Mission Prevalence: essential" in result
26+ assert "Public Well-being Impact: irreversible" in result
27+
28+
29+ def test_to_yaml_with_empty_value ():
30+ assert to_yaml (None ) == ""
31+ assert to_yaml ([]) == ""
32+ assert to_yaml ("" ) == ""
33+
34+
35+ def test_to_yaml_with_non_serializable_value ():
36+ result = to_yaml ("plain string" )
37+ assert isinstance (result , str )
38+
0 commit comments