File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed
tests/integration_tests/style Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 4
4
"""Tests enforcing git repository structure"""
5
5
6
6
import subprocess
7
+ from pathlib import Path
8
+
9
+ import yaml
7
10
8
11
9
12
def test_repo_no_spaces_in_paths ():
@@ -21,3 +24,15 @@ def test_repo_no_spaces_in_paths():
21
24
)
22
25
# If grep doesn't find any, it will exit with status 1. Otherwise 0
23
26
assert res .returncode == 1 , "Some files have spaces:\n " + res .stdout .decode ()
27
+
28
+
29
+ def test_repo_validate_yaml ():
30
+ """
31
+ Ensure all YAML files are valid
32
+
33
+ @type: style
34
+ """
35
+
36
+ repo_root = Path (".." )
37
+ for path in repo_root .rglob ("*.y*ml" ):
38
+ yaml .safe_load (path .open (encoding = "utf-8" ))
Original file line number Diff line number Diff line change 4
4
5
5
from pathlib import Path
6
6
7
- import yaml
8
7
from openapi_spec_validator import validate_spec
9
8
from openapi_spec_validator .readers import read_from_filename
10
9
11
10
12
- def check_yaml_style (yaml_spec ):
13
- """Check if the swagger definition is correctly formatted."""
14
- with open (yaml_spec , "r" , encoding = "utf-8" ) as file_stream :
15
- try :
16
- yaml .safe_load (file_stream )
17
- # pylint: disable=broad-except
18
- except Exception as exception :
19
- print (str (exception ))
20
-
21
-
22
11
def validate_swagger (swagger_spec ):
23
12
"""Fail if OpenAPI spec is not followed."""
24
13
spec_dict , _ = read_from_filename (swagger_spec )
@@ -32,5 +21,4 @@ def test_firecracker_swagger():
32
21
@type: style
33
22
"""
34
23
swagger_spec = Path ("../src/api_server/swagger/firecracker.yaml" )
35
- check_yaml_style (swagger_spec )
36
24
validate_swagger (swagger_spec )
You can’t perform that action at this time.
0 commit comments