1818from unittest .mock import patch
1919
2020from ipdb import set_trace
21- from jsonschema .validators import Draft202012Validator
2221from pytest import fail
2322
2423from opentelemetry .file_configuration import (
4039def test_create_object ():
4140
4241 file_configuration = load_file_configuration (
43- data_path .joinpath ("file_configuration" ).joinpath ("file_configuration_0.yaml" )
42+ data_path .joinpath ("file_configuration" ).
43+ joinpath ("file_configuration_0.yaml" )
4444 )
4545
4646 schema_path = data_path .joinpath ("schema" ).joinpath (
4747 "opentelemetry_file_configuration.json"
4848 )
4949
50+ resolved_schema = resolve_schema (schema_path )
51+
5052 try :
51- validate_file_configuration (schema_path , file_configuration )
53+ validate_file_configuration (resolved_schema , file_configuration )
5254 except Exception as error :
5355 fail (f"Unexpected exception raised: { error } " )
5456
55- processed_schema = process_schema (resolve_schema ( schema_path ) )
57+ processed_schema = process_schema (resolved_schema )
5658
5759 set_resource (create_object (file_configuration , processed_schema , "resource" ))
5860
@@ -101,28 +103,34 @@ def test_create_object():
101103
102104@patch .dict (environ , {"OTEL_BLRB_EXPORT_TIMEOUT" : "943" }, clear = True )
103105def test_substitute_environment_variables ():
106+
104107 file_configuration = load_file_configuration (
105- data_path .joinpath ("file_configuration" ).joinpath ("file_configuration_1.yaml" )
108+ data_path .joinpath ("file_configuration" ).
109+ joinpath ("file_configuration_1.yaml" )
106110 )
107111
108112 schema_path = data_path .joinpath ("schema" ).joinpath (
109113 "opentelemetry_file_configuration.json"
110114 )
111115
112- processed_schema = process_schema (resolve_schema (schema_path ))
116+ resolved_schema = resolve_schema (schema_path )
117+
118+ processed_schema = process_schema (resolved_schema )
119+
113120 file_configuration = substitute_environment_variables (
114121 file_configuration , processed_schema
115122 )
116123
124+ try :
125+ validate_file_configuration (resolved_schema , file_configuration )
126+ except Exception as error :
127+ fail (f"Unexpected exception raised: { error } " )
128+
117129 assert (
118130 file_configuration ["logger_provider" ]["processors" ][0 ]["batch" ][
119131 "export_timeout"
120132 ]
121133 ) == 943
122- try :
123- validate_file_configuration (schema_path , file_configuration )
124- except Exception as error :
125- fail (f"Unexpected exception raised: { error } " )
126134
127135
128136def test_render (tmpdir ):
@@ -142,43 +150,25 @@ def test_render(tmpdir):
142150 fail (f"Unexpected exception raised: { error } " )
143151
144152
145- def test_subschemas ():
146-
147- schema_path = data_path .joinpath ("schema" ).joinpath (
148- "opentelemetry_file_configuration.json"
149- )
150- resolved_schema = resolve_schema (schema_path )
151- resolved_schema
152-
153- # FIXME once the schema has been resolved, we get a dictionary. Add to this
154- # dictionary the schema components of each plugin component sub schema then
155- # use the resulting schema dictionary to do the validation.
156-
157- file_configuration = load_file_configuration (
158- data_path .joinpath ("file_configuration" ).joinpath ("file_configuration_0.yaml" )
159- )
160-
161- # FIXME do the same for file_configuration components
162-
163- Draft202012Validator (resolved_schema ).validate (file_configuration )
164-
165-
166153def test_dry_run ():
167154
168155 file_configuration = load_file_configuration (
169- data_path .joinpath ("file_configuration" ).joinpath ("file_configuration_0.yaml" )
156+ data_path .joinpath ("file_configuration" ).
157+ joinpath ("file_configuration_0.yaml" )
170158 )
171159
172160 schema_path = data_path .joinpath ("schema" ).joinpath (
173161 "opentelemetry_file_configuration.json"
174162 )
175163
164+ resolved_schema = resolve_schema (schema_path )
165+
176166 try :
177- validate_file_configuration (schema_path , file_configuration )
167+ validate_file_configuration (resolved_schema , file_configuration )
178168 except Exception as error :
179169 fail (f"Unexpected exception raised: { error } " )
180170
181- processed_schema = process_schema (resolve_schema ( schema_path ) )
171+ processed_schema = process_schema (resolved_schema )
182172
183173 set_resource (create_object (file_configuration , processed_schema , "resource" ))
184174
0 commit comments