mirror of
https://github.com/badges/shields.git
synced 2025-11-09 12:40:59 +03:00
Add [PythonVersionFromToml] shield (#9516)
* Add PythonVersionFromToml Added new shield per issue #9410 The shield display required python versions for packages based on pyproject.toml * Add tests for PythonVersionFromToml * Improve docs for tests regex * Improve title and description Rename and updated description to bring into focus that only PEP 621 complaint pyproject.toml files are supported. Solves review https://github.com/badges/shields/pull/9516#discussion_r1310648023 * replace complex regex with @renovate/pep440 solves review https://github.com/badges/shields/pull/9516#discussion_r1310648881
This commit is contained in:
27
services/python/python-version-from-toml.tester.js
Normal file
27
services/python/python-version-from-toml.tester.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import Joi from 'joi'
|
||||
import pep440 from '@renovate/pep440'
|
||||
import { createServiceTester } from '../tester.js'
|
||||
export const t = await createServiceTester()
|
||||
|
||||
const validatePep440 = (value, helpers) => {
|
||||
if (!pep440.validRange(value)) {
|
||||
return helpers.error('any.invalid')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
const isCommaSeparatedPythonVersions = Joi.string().custom(validatePep440)
|
||||
|
||||
t.create('python versions (valid)')
|
||||
.get(
|
||||
'/python/required-version-toml.json?tomlFilePath=https://raw.githubusercontent.com/numpy/numpy/main/pyproject.toml',
|
||||
)
|
||||
.expectBadge({ label: 'python', message: isCommaSeparatedPythonVersions })
|
||||
|
||||
t.create(
|
||||
'python versions - valid toml with missing python-requires field (invalid)',
|
||||
)
|
||||
.get(
|
||||
'/python/required-version-toml.json?tomlFilePath=https://raw.githubusercontent.com/django/django/main/pyproject.toml',
|
||||
)
|
||||
.expectBadge({ label: 'python', message: 'invalid response data' })
|
||||
Reference in New Issue
Block a user