<s> import glob <EOL> import json <EOL> import os <EOL> import jsonschema <EOL> from testtools import content <EOL> from os_client_config import defaults <EOL> from os_client_config . tests import base <EOL> class TestConfig ( base . TestCase ) : <EOL> def json_diagnostics ( self , exc_info ) : <EOL> self . addDetail ( '<STR_LIT:filename>' , content . text_content ( self . filename ) ) <EOL> for error in sorted ( self . validator . iter_errors ( self . json_data ) ) : <EOL> self . addDetail ( '<STR_LIT>' , content . text_content ( str ( error ) ) ) <EOL> def test_defaults_valid_json ( self ) : <EOL> _schema_path = os . path . join ( <EOL> os . path . dirname ( os . path . realpath ( defaults . __file__ ) ) , <EOL> '<STR_LIT>' ) <EOL> schema = json . load ( open ( _schema_path , '<STR_LIT:r>' ) ) <EOL> self . validator = jsonschema . Draft4Validator ( schema ) <EOL> self . addOnException ( self . json_diagnostics ) <EOL> self . filename = os . path . join ( <EOL> os . path . dirname ( os . path . realpath ( defaults . __file__ ) ) , <EOL> '<STR_LIT>' ) <EOL> self . json_data = json . load ( open ( self . filename , '<STR_LIT:r>' ) ) <EOL> self . assertTrue ( self . validator . is_valid ( self . json_data ) ) <EOL> def test_vendors_valid_json ( self ) : <EOL> _schema_path = os . path . join ( <EOL> os . path . dirname ( os . path . realpath ( defaults . __file__ ) ) , <EOL> '<STR_LIT>' ) <EOL> schema = json . load ( open ( _schema_path , '<STR_LIT:r>' ) ) <EOL> self . validator = jsonschema . Draft4Validator ( schema ) <EOL> self . addOnException ( self . json_diagnostics ) <EOL> _vendors_path = os . path . join ( <EOL> os . path . dirname ( os . path . realpath ( defaults . __file__ ) ) , <EOL> '<STR_LIT>' ) <EOL> for self . filename in glob . glob ( os . path . join ( _vendors_path , '<STR_LIT>' ) ) : <EOL> self . json_data = json . load ( open ( self . filename , '<STR_LIT:r>' ) ) <EOL> self . assertTrue ( self . validator . is_valid ( self . json_data ) ) </s>
