This commit is contained in:
@@ -25,6 +25,7 @@ test('upload MIME types are detected from content and not trusted request metada
|
||||
|
||||
test('Python API tools are syntax-valid and contain reusable 401 authentication handling', async () => {
|
||||
const toolsDir = path.join(root, 'tools/python');
|
||||
const coverageRunnerPath = path.join(root, 'test-support/python_coverage_runner.py');
|
||||
const names = (await fs.readdir(toolsDir)).filter(name => name.endsWith('.py'));
|
||||
const expected = [
|
||||
'append_route.py', 'common.py', 'create_audio.py', 'create_picture.py', 'create_poi.py',
|
||||
@@ -36,15 +37,21 @@ test('Python API tools are syntax-valid and contain reusable 401 authentication
|
||||
expected.toSorted((left, right) => left.localeCompare(right))
|
||||
);
|
||||
|
||||
const compile = spawnSync('python3', ['-m', 'py_compile', ...names.map(name => path.join(toolsDir, name))], {
|
||||
const compile = spawnSync('python3', [
|
||||
'-m', 'py_compile',
|
||||
...names.map(name => path.join(toolsDir, name)),
|
||||
coverageRunnerPath
|
||||
], {
|
||||
cwd: root,
|
||||
encoding: 'utf8'
|
||||
});
|
||||
assert.equal(compile.status, 0, compile.stderr);
|
||||
await fs.rm(path.join(toolsDir, '__pycache__'), { recursive: true, force: true });
|
||||
await fs.rm(path.join(root, 'test-support/__pycache__'), { recursive: true, force: true });
|
||||
|
||||
const common = await read('tools/python/common.py');
|
||||
const sonar = await read('sonar-project.properties');
|
||||
const coverageRunner = await read('test-support/python_coverage_runner.py');
|
||||
const requirements = await read('requirements-dev.txt');
|
||||
const pkg = JSON.parse(await read('package.json'));
|
||||
assert.match(common, /class ApiClient/);
|
||||
@@ -58,7 +65,10 @@ test('Python API tools are syntax-valid and contain reusable 401 authentication
|
||||
assert.match(common, /traceback\.print_exception/);
|
||||
assert.doesNotMatch(common, /Content-Type:.*application\/octet-stream/);
|
||||
assert.match(pkg.scripts['test:coverage'], /test:coverage:python/);
|
||||
assert.match(pkg.scripts['test:coverage:python'], /coverage\/python\/coverage\.xml/);
|
||||
assert.match(pkg.scripts['test:coverage:python'], /python_coverage_runner\.py/);
|
||||
assert.match(coverageRunner, /coverage\/python\/coverage\.xml/);
|
||||
assert.match(coverageRunner, /--target/);
|
||||
assert.match(coverageRunner, /traceback\.print_exc/);
|
||||
assert.match(sonar, /sonar\.python\.coverage\.reportPaths=coverage\/python\/coverage\.xml/);
|
||||
assert.match(requirements, /^coverage==/m);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user