Skip to content

Commit

Permalink
Add tests for PythonVersionFromToml
Browse files Browse the repository at this point in the history
  • Loading branch information
jNullj committed Aug 25, 2023
1 parent 8855a14 commit cf55f62
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions services/python/python-version-from-toml.tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Joi from 'joi'
import { createServiceTester } from '../tester.js'
export const t = await createServiceTester()

const isCommaSeparatedPythonVersions = Joi.string().regex(
/^\s*(?:(?:===|!=|<=|>=|<|>)\s*)?((?:(?:\d+!)?(?:\d+(?:\.\d+)*))(?:(?:[abc]|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?)(?:\s*,\s*(?:(?:===|!=|<=|>=|<|>)\s*)?((?:(?:\d+!)?(?:\d+(?:\.\d+)*))(?:(?:[abc]|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?))*\s*$/,
)

t.create('python versions (valid)')
.get(
'/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(
'/required-version-toml.json?tomlFilePath=https://raw.githubusercontent.com/django/django/main/pyproject.toml',
)
.expectBadge({ label: 'python', message: 'invalid response data' })

0 comments on commit cf55f62

Please sign in to comment.