Skip to content
Snippets Groups Projects
Commit f61569ce authored by geant-release-service's avatar geant-release-service
Browse files

Finished release 0.1.

parents 0ebf2349 7db6589a
Branches
Tags
No related merge requests found
Showing
with 332 additions and 0 deletions
This diff is collapsed.
compendium_v2/static/images/compendium_header.png

50.6 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<div id="root"></div>
<script src="bundle.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<div id="root"></div>
<script src="static/bundle.js"></script>
</body>
</html>
\ No newline at end of file
{
"str-param": "some string",
"int-param": -1234
}
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.. api intro
API Protocol
===============
This module implements a Flask-based webservice which
communicates with clients over HTTP.
Responses to valid requests are returned as JSON messages.
The server will therefore return an error unless
`application/json` is in the `Accept` request header field.
HTTP communication and JSON grammar details are
beyond the scope of this document.
Please refer to [RFC 2616](https://tools.ietf.org/html/rfc2616)
and www.json.org for more details.
.. contents:: :local:
.. automodule:: compendium_v2.routes.default
.. automodule:: compendium_v2.routes.api
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from importlib import import_module
from docutils.parsers.rst import Directive
from docutils import nodes
from sphinx import addnodes
import json
import os
import sys
sys.path.insert(0, os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'..', '..', 'compendium_v2')))
class RenderAsJSON(Directive):
# cf. https://stackoverflow.com/a/59883833
required_arguments = 1
def run(self):
module_path, member_name = self.arguments[0].rsplit('.', 1)
member_data = getattr(import_module(module_path), member_name)
code = json.dumps(member_data, indent=2)
literal = nodes.literal_block(code, code)
literal['language'] = 'json'
return [
addnodes.desc_name(text=member_name),
addnodes.desc_content('', literal)
]
def setup(app):
app.add_directive('asjson', RenderAsJSON)
# -- Project information -----------------------------------------------------
# TODO: give this a better project name
project = 'compendium-v2'
copyright = '2022, GÉANT Vereniging'
author = 'swd@geant.org'
# The full version, including alpha/beta/rc tags
release = '0.0'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinx.ext.autodoc',
'sphinx.ext.coverage'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Both the class’ and the __init__ method’s docstring
# are concatenated and inserted.
autoclass_content = "both"
autodoc_typehints = "none"
compendium_v2
========================================
This project is a Flask-based webservice serving json-based data, and
a React web application that consumes and renders the json data.
.. toctree::
:maxdepth: 2
:caption: Contents:
api
setup.py 0 → 100644
from setuptools import setup, find_packages
setup(
name='compendium-v2',
version="0.1",
author='GEANT',
author_email='swd@geant.org',
description='Flask and React project for displaying '
'Compendium related reports and survey',
url=('https://gitlab.geant.net/live-projects/compendium-v2'),
packages=find_packages(),
install_requires=[
'jsonschema',
'flask',
'flask-cors'
],
include_package_data=True,
)
import json
import os
import tempfile
import pytest
import compendium_v2
@pytest.fixture
def data_config_filename():
test_config_data = {
'str-param': 'test data string',
'int-param': -47
}
with tempfile.NamedTemporaryFile() as f:
f.write(json.dumps(test_config_data).encode('utf-8'))
f.flush()
yield f.name
@pytest.fixture
def client(data_config_filename):
os.environ['SETTINGS_FILENAME'] = data_config_filename
with compendium_v2.create_app().test_client() as c:
yield c
import json
import jsonschema
import pytest
from compendium_v2.routes.default import VERSION_SCHEMA
from compendium_v2.routes.api import THING_LIST_SCHEMA
@pytest.mark.parametrize(
'endpoint',
['version', 'api/things'])
def test_bad_accept(endpoint, client):
rv = client.post(
endpoint,
headers={'Accept': ['text/html']})
assert rv.status_code == 406
def test_version_request(client):
rv = client.post(
'version',
headers={'Accept': ['application/json']})
assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(result, VERSION_SCHEMA)
def test_things(client):
rv = client.post(
'api/things',
headers={'Accept': ['application/json']})
assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(result, THING_LIST_SCHEMA)
import json
import jsonschema
import pytest
from compendium_v2.routes.service_matrix import SERVICE_MATRIX_SCHEMA
@pytest.mark.parametrize(
'endpoint',
['service-matrix'])
def test_bad_accept(endpoint, client):
rv = client.get(
endpoint,
headers={'Accept': ['text/html']})
assert rv.status_code == 406
def test_service_matrix(client):
rv = client.get(
'service-matrix',
headers={'Accept': ['application/json']})
assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(result, SERVICE_MATRIX_SCHEMA)
tox.ini 0 → 100644
[tox]
envlist = py39
[flake8]
exclude = ./.tox,./webapp
[testenv]
deps =
coverage
flake8
-r requirements.txt
commands =
coverage erase
coverage run --source compendium_v2 -m pytest {posargs}
coverage xml
coverage html
coverage report --fail-under 85
flake8
sphinx-build -M html docs/source docs/build
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
],
"@babel/plugin-proposal-class-properties"
]
}
**/*.css
**/*.scss
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment