Skip to content
Snippets Groups Projects
Verified Commit 79fda01a authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Initial commit

parent 832e42e9
No related branches found
No related tags found
No related merge requests found
Pipeline #3938 passed
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
stages:
- test
test_schemas:
stage: test
image: python:3
cache:
key: "$CI_PROJECT_ID__pip_cache"
paths:
- "$PIP_CACHE_DIR"
before_script:
- pip3 install .[dev]
script:
- pytest tests/
tags:
- docker
{
"version": "0.1",
"means": [
{
"provider": "flattr",
"id": "Alice",
"weight": 0,
"url": "https://flattr.com/@Alice"
},
{
"provider": "custom",
"id": "sendmecash",
"name": "Cash",
"weight": 1,
"description": "I live here, you can send me money directly"
},
{
"provider": "unkown",
"id": "freetips",
"name": "Tip me on freetips",
"weight": 2,
"description": "This is the best place to tip me"
}
]
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"id": "http://retribute.me/ns/schema/0.1.json",
"description": "Retribute.me schema version 0.1",
"type": "object",
"additionalProperties": false,
"required": [
"version",
"means"
],
"properties": {
"version": {
"description": "The schema version, must be 0.1.",
"enum": [
"0.1"
]
},
"means": {
"description": "A list of retribution means",
"type": "array",
"items": { "$ref": "#/definitions/mean" }
}
},
"definitions": {
"mean": {
"description": "A single retribution mean",
"type": "object",
"required": ["provider", "id", "weight"],
"minItems": 1,
"properties": {
"provider": {
"type": "string",
"description": "A provider id",
"examples": [
"flattr",
"liberapay",
"patreon",
"tipeee",
"paypal",
"wiretransfer",
"bitcoin",
"wiretransfer",
"custom"
]
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"weight": {
"type": "integer",
"minimum": 0,
"description": "Weight of the retribution mean. Higher values mean this mean is preferred to others"
}
}
}
}
}
[metadata]
name = retribute-me
description = "Utils around the retribute.me specification"
version = 0.1.dev0
author = Eliot Berriot
author_email = contact@eliotberriot.com
url = https://dev.funkwhale.audio/retribute.me/spec
long_description = file: README.md
license = AGPL3
keywords = downloader, network, archive
classifiers =
Development Status :: 3 - Alpha
License :: OSI Approved :: AGPL
Natural Language :: English
Programming Language :: Python :: 3.6
[options]
zip_safe = True
include_package_data = True
packages = find:
install_requires =
jsonschema
[options.extras_require]
dev =
ipdb
pytest
[options.packages.find]
exclude =
tests
[bdist_wheel]
universal = 1
[tool:pytest]
testpaths = tests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup
setup()
import json
import jsonschema
import pytest
import os
SCHEMAS_DIR = os.path.join(
os.path.dirname(os.path.abspath(os.path.dirname(__file__))),
'schemas'
)
@pytest.mark.parametrize('version', ['0.1'])
def test_schema_validation(version):
with open(os.path.join(SCHEMAS_DIR, version, 'schema.json')) as f:
schema = json.loads(f.read())
with open(os.path.join(SCHEMAS_DIR, version, 'example.json')) as f:
example = json.loads(f.read())
assert jsonschema.validate(instance=example, schema=schema) is None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment