fix: указать кодировку utf-8 при чтении файлов в скриптах
Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
@@ -8,8 +8,8 @@ import re
|
|||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
lab = json.loads((ROOT/'lab.json').read_text())['number']
|
lab = json.loads((ROOT/'lab.json').read_text(encoding='utf-8'))['number']
|
||||||
spec = json.loads((ROOT/'contracts/openapi.json').read_text())
|
spec = json.loads((ROOT/'contracts/openapi.json').read_text(encoding='utf-8'))
|
||||||
assert spec['openapi']=='3.1.0'
|
assert spec['openapi']=='3.1.0'
|
||||||
assert spec['info']['version']=='1.%d.0'%lab
|
assert spec['info']['version']=='1.%d.0'%lab
|
||||||
operation_ids = set()
|
operation_ids = set()
|
||||||
@@ -41,11 +41,11 @@ def main():
|
|||||||
assert ('/api/v1/auth/sessions' in spec['paths']) == (lab>=2)
|
assert ('/api/v1/auth/sessions' in spec['paths']) == (lab>=2)
|
||||||
assert ('/api/v1/attachments/{attachment_id}' in spec['paths']) == (lab>=4)
|
assert ('/api/v1/attachments/{attachment_id}' in spec['paths']) == (lab>=4)
|
||||||
for file in list((ROOT/'tests').glob('*.py'))+list((ROOT/'scripts').glob('*.py')):
|
for file in list((ROOT/'tests').glob('*.py'))+list((ROOT/'scripts').glob('*.py')):
|
||||||
ast.parse(file.read_text(),filename=str(file))
|
ast.parse(file.read_text(encoding='utf-8'),filename=str(file))
|
||||||
for file in ROOT.rglob('*.json'):
|
for file in ROOT.rglob('*.json'):
|
||||||
if any(part in {'.git','.venv','node_modules','vendor','output'} for part in file.parts):
|
if any(part in {'.git','.venv','node_modules','vendor','output'} for part in file.parts):
|
||||||
continue
|
continue
|
||||||
json.loads(file.read_text())
|
json.loads(file.read_text(encoding='utf-8'))
|
||||||
for required in ('README.md','COURSE.md','CONTRIBUTING.md','REPORT.md','contracts/README.md','tests/smoke.py','tests/README.md'):
|
for required in ('README.md','COURSE.md','CONTRIBUTING.md','REPORT.md','contracts/README.md','tests/smoke.py','tests/README.md'):
|
||||||
assert (ROOT/required).is_file(), 'missing '+required
|
assert (ROOT/required).is_file(), 'missing '+required
|
||||||
print('PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.')
|
print('PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.')
|
||||||
|
|||||||
@@ -6,17 +6,17 @@ from openapi_spec_validator import validate
|
|||||||
from jsonschema import Draft202012Validator
|
from jsonschema import Draft202012Validator
|
||||||
|
|
||||||
root = Path(__file__).resolve().parents[1]
|
root = Path(__file__).resolve().parents[1]
|
||||||
spec = json.loads((root/'contracts/openapi.json').read_text())
|
spec = json.loads((root/'contracts/openapi.json').read_text(encoding='utf-8'))
|
||||||
validate(spec)
|
validate(spec)
|
||||||
from referencing import Registry, Resource
|
from referencing import Registry, Resource
|
||||||
# The base URI resolves local #/components references inside examples.
|
# The base URI resolves local #/components references inside examples.
|
||||||
resource = dict(spec, **{'$schema': 'https://json-schema.org/draft/2020-12/schema'})
|
resource = dict(spec, **{'$schema': 'https://json-schema.org/draft/2020-12/schema'})
|
||||||
registry = Registry().with_resource('urn:mtusi:openapi', Resource.from_contents(resource))
|
registry = Registry().with_resource('urn:mtusi:openapi', Resource.from_contents(resource))
|
||||||
for name, example in json.loads((root/'contracts/examples.json').read_text()).items():
|
for name, example in json.loads((root/'contracts/examples.json').read_text(encoding='utf-8')).items():
|
||||||
schema = {'$ref': 'urn:mtusi:openapi#/components/schemas/' + name}
|
schema = {'$ref': 'urn:mtusi:openapi#/components/schemas/' + name}
|
||||||
Draft202012Validator(schema, registry=registry).validate(example)
|
Draft202012Validator(schema, registry=registry).validate(example)
|
||||||
for path in (root/'contracts').glob('*.schema.json'):
|
for path in (root/'contracts').glob('*.schema.json'):
|
||||||
schema = json.loads(path.read_text())
|
schema = json.loads(path.read_text(encoding='utf-8'))
|
||||||
Draft202012Validator.check_schema(schema)
|
Draft202012Validator.check_schema(schema)
|
||||||
for example in schema.get('examples',[]):
|
for example in schema.get('examples',[]):
|
||||||
Draft202012Validator(schema).validate(example)
|
Draft202012Validator(schema).validate(example)
|
||||||
|
|||||||
Reference in New Issue
Block a user