1
0
mirror of https://github.com/badges/shields.git synced 2025-04-18 19:44:04 +03:00
shields/services/python/python-version-from-toml.tester.js

28 lines
920 B
JavaScript

import Joi from 'joi'
import pep440 from '@renovatebot/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/psf/requests/main/pyproject.toml',
)
.expectBadge({ label: 'python', message: 'invalid response data' })