mirror of
https://github.com/gsi-upm/senpy
synced 2025-09-18 20:42:22 +00:00
Compare commits
1 Commits
0.8.0-fix1
...
0.7.1-5-g8
Author | SHA1 | Date | |
---|---|---|---|
|
87589e994a |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,5 +6,3 @@ build
|
|||||||
README.html
|
README.html
|
||||||
__pycache__
|
__pycache__
|
||||||
VERSION
|
VERSION
|
||||||
Dockerfile-*
|
|
||||||
Dockerfile
|
|
@@ -1,4 +1,4 @@
|
|||||||
image: gsiupm/dockermake:latest
|
image: docker:latest
|
||||||
|
|
||||||
|
|
||||||
# When using dind, it's wise to use the overlayfs driver for
|
# When using dind, it's wise to use the overlayfs driver for
|
||||||
@@ -6,68 +6,75 @@ image: gsiupm/dockermake:latest
|
|||||||
variables:
|
variables:
|
||||||
DOCKER_DRIVER: overlay
|
DOCKER_DRIVER: overlay
|
||||||
DOCKERFILE: Dockerfile
|
DOCKERFILE: Dockerfile
|
||||||
VERSION: $CI_BUILD_REF
|
|
||||||
|
before_script:
|
||||||
|
- sh version.sh > senpy/VERSION
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- images
|
- images
|
||||||
- release
|
- release
|
||||||
- clean
|
|
||||||
|
|
||||||
.test: &test_definition
|
.test: &test_definition
|
||||||
|
variables:
|
||||||
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .eggs/
|
||||||
|
- "$CI_PROJECT_DIR/pip-cache"
|
||||||
|
- .venv
|
||||||
|
key: "$CI_PROJECT_NAME"
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- make -e test-$PYTHON_VERSION
|
- pip install --use-wheel -U pip setuptools virtualenv
|
||||||
|
- virtualenv .venv/$PYTHON_VERSION
|
||||||
|
- source .venv/$PYTHON_VERSION/bin/activate
|
||||||
|
- pip install --use-wheel -r requirements.txt
|
||||||
|
- pip install --use-wheel -r test-requirements.txt
|
||||||
|
- py.test --cov=senpy --cov-report term-missing
|
||||||
|
- python
|
||||||
|
|
||||||
test-3.5:
|
test-3.5:
|
||||||
<<: *test_definition
|
<<: *test_definition
|
||||||
variables:
|
image: "python:3.5"
|
||||||
PYTHON_VERSION: "3.5"
|
|
||||||
|
|
||||||
test-2.7:
|
test-2.7:
|
||||||
<<: *test_definition
|
<<: *test_definition
|
||||||
variables:
|
image: "python:2.7"
|
||||||
PYTHON_VERSION: "2.7"
|
|
||||||
|
|
||||||
|
|
||||||
.image: &image_definition
|
.image: &image_definition
|
||||||
stage: images
|
variables:
|
||||||
|
PYTHON_VERSION: "3.5"
|
||||||
before_script:
|
before_script:
|
||||||
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
|
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- make -e push-$PYTHON_VERSION
|
- docker build -f Dockerfile-3.5 . -t $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG-$PYTHON_VERSION
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG-$PYTHON_VERSION
|
||||||
|
stage: images
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
- master
|
|
||||||
- triggers
|
- triggers
|
||||||
|
|
||||||
image-3.5:
|
image-3.5:
|
||||||
<<: *image_definition
|
<<: *image_definition
|
||||||
variables:
|
variables:
|
||||||
PYTHON_VERSION: "3.5"
|
PYTHON_VERSION: "3.5"
|
||||||
VERSION: $CI_BUILD_TAG
|
|
||||||
IMAGENAME: $CI_REGISTRY_IMAGE
|
|
||||||
|
|
||||||
image-2.7:
|
image-2.7:
|
||||||
<<: *image_definition
|
<<: *image_definition
|
||||||
variables:
|
variables:
|
||||||
PYTHON_VERSION: "2.7"
|
PYTHON_VERSION: "2.7"
|
||||||
VERSION: $CI_BUILD_TAG
|
|
||||||
IMAGENAME: $CI_REGISTRY_IMAGE
|
|
||||||
|
|
||||||
image-latest:
|
image-latest:
|
||||||
stage: release
|
stage: release
|
||||||
variables:
|
|
||||||
IMAGENAME: $CI_REGISTRY_IMAGE
|
|
||||||
before_script:
|
before_script:
|
||||||
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
|
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- make -e push-latest
|
- docker build -f Dockerfile . -t $CI_REGISTRY_IMAGE
|
||||||
|
- docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG
|
||||||
|
- docker push $CI_REGISTRY_IMAGE
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- triggers
|
- triggers
|
||||||
|
|
||||||
clean :
|
|
||||||
stage: clean
|
|
||||||
script:
|
|
||||||
- make -e clean
|
|
@@ -1,5 +0,0 @@
|
|||||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
|
||||||
sha: e626cd57090d8df0be21e4df0f4e55cc3511d6ab
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
- id: check-json
|
|
1
Dockerfile
Symbolic link
1
Dockerfile
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
Dockerfile-3.5
|
21
Dockerfile-2.7
Normal file
21
Dockerfile-2.7
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from python:2.7
|
||||||
|
|
||||||
|
RUN mkdir /cache/
|
||||||
|
ENV PIP_CACHE_DIR=/cache/
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
ADD requirements.txt /usr/src/app/
|
||||||
|
RUN pip install --use-wheel -r requirements.txt
|
||||||
|
ADD . /usr/src/app/
|
||||||
|
RUN pip install .
|
||||||
|
|
||||||
|
|
||||||
|
VOLUME /data/
|
||||||
|
|
||||||
|
RUN mkdir /senpy-plugins/
|
||||||
|
|
||||||
|
WORKDIR /senpy-plugins/
|
||||||
|
ONBUILD ADD . /senpy-plugins/
|
||||||
|
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
||||||
|
|
||||||
|
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
21
Dockerfile-3.4
Normal file
21
Dockerfile-3.4
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from python:3.4
|
||||||
|
|
||||||
|
RUN mkdir /cache/
|
||||||
|
ENV PIP_CACHE_DIR=/cache/
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
ADD requirements.txt /usr/src/app/
|
||||||
|
RUN pip install --use-wheel -r requirements.txt
|
||||||
|
ADD . /usr/src/app/
|
||||||
|
RUN pip install .
|
||||||
|
|
||||||
|
|
||||||
|
VOLUME /data/
|
||||||
|
|
||||||
|
RUN mkdir /senpy-plugins/
|
||||||
|
|
||||||
|
WORKDIR /senpy-plugins/
|
||||||
|
ONBUILD ADD . /senpy-plugins/
|
||||||
|
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
||||||
|
|
||||||
|
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
21
Dockerfile-3.5
Normal file
21
Dockerfile-3.5
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
FROM python:3.5
|
||||||
|
|
||||||
|
RUN mkdir /cache/
|
||||||
|
ENV PIP_CACHE_DIR=/cache/
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
ADD requirements.txt /usr/src/app/
|
||||||
|
RUN pip install --use-wheel -r requirements.txt
|
||||||
|
ADD . /usr/src/app/
|
||||||
|
RUN pip install .
|
||||||
|
|
||||||
|
|
||||||
|
VOLUME /data/
|
||||||
|
|
||||||
|
RUN mkdir /senpy-plugins/
|
||||||
|
|
||||||
|
WORKDIR /senpy-plugins/
|
||||||
|
ONBUILD ADD . /senpy-plugins/
|
||||||
|
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
||||||
|
|
||||||
|
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
33
Dockerfile.deps
Normal file
33
Dockerfile.deps
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from python:2.7
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get -y install git
|
||||||
|
RUN mkdir -p /senpy-plugins
|
||||||
|
|
||||||
|
RUN apt-get -y install python-numpy
|
||||||
|
RUN apt-get -y install python-scipy
|
||||||
|
RUN apt-get -y install python-sklearn
|
||||||
|
RUN apt-get -y install python-gevent
|
||||||
|
RUN apt-get -y install libopenblas-dev
|
||||||
|
RUN apt-get -y install gfortran
|
||||||
|
RUN apt-get -y install libxml2-dev libxslt1-dev python-dev
|
||||||
|
|
||||||
|
#RUN pip install --upgrade pip
|
||||||
|
|
||||||
|
ADD id_rsa /root/.ssh/id_rsa
|
||||||
|
RUN chmod 700 /root/.ssh/id_rsa
|
||||||
|
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
|
||||||
|
|
||||||
|
RUN git clone https://github.com/gsi-upm/senpy /usr/src/app/
|
||||||
|
RUN git clone git@github.com:gsi-upm/senpy-plugins-enterprise /senpy-plugins/enterprise
|
||||||
|
RUN git clone https://github.com/gsi-upm/senpy-plugins-community /senpy-plugins/community
|
||||||
|
|
||||||
|
RUN pip install /usr/src/app
|
||||||
|
RUN pip install --no-use-wheel -r /senpy-plugins/enterprise/requirements.txt
|
||||||
|
RUN python -m nltk.downloader stopwords
|
||||||
|
RUN python -m nltk.downloader punkt
|
||||||
|
RUN python -m nltk.downloader maxent_treebank_pos_tagger
|
||||||
|
RUN python -m nltk.downloader wordnet
|
||||||
|
|
||||||
|
WORKDIR /senpy-plugins
|
||||||
|
ENTRYPOINT ["python", "-m", "senpy", "-f", ".", "--host", "0.0.0.0"]
|
@@ -1,22 +1,21 @@
|
|||||||
from python:{{PYVERSION}}
|
from python:{{PYVERSION}}
|
||||||
|
|
||||||
MAINTAINER J. Fernando Sánchez <jf.sanchez@upm.es>
|
RUN mkdir /cache/
|
||||||
|
ENV PIP_CACHE_DIR=/cache/
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
ADD requirements.txt /usr/src/app/
|
||||||
|
RUN pip install --use-wheel -r requirements.txt
|
||||||
|
ADD . /usr/src/app/
|
||||||
|
RUN pip install .
|
||||||
|
|
||||||
RUN mkdir /cache/ /senpy-plugins /data/
|
|
||||||
|
|
||||||
VOLUME /data/
|
VOLUME /data/
|
||||||
|
|
||||||
ENV PIP_CACHE_DIR=/cache/
|
RUN mkdir /senpy-plugins/
|
||||||
|
|
||||||
ONBUILD COPY . /senpy-plugins/
|
WORKDIR /senpy-plugins/
|
||||||
|
ONBUILD ADD . /senpy-plugins/
|
||||||
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
||||||
ONBUILD WORKDIR /senpy-plugins/
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
COPY test-requirements.txt requirements.txt /usr/src/app/
|
|
||||||
RUN pip install --use-wheel -r test-requirements.txt -r requirements.txt
|
|
||||||
COPY . /usr/src/app/
|
|
||||||
RUN pip install --no-deps --no-index .
|
|
||||||
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
51
Makefile
51
Makefile
@@ -1,17 +1,17 @@
|
|||||||
PYVERSIONS=3.5 2.7
|
PYVERSIONS=3.5 3.4 2.7
|
||||||
PYMAIN=$(firstword $(PYVERSIONS))
|
PYMAIN=$(firstword $(PYVERSIONS))
|
||||||
NAME=senpy
|
NAME=senpy
|
||||||
REPO=gsiupm
|
REPO=gsiupm
|
||||||
VERSION=$(shell git describe --tags --dirty 2>/dev/null)
|
VERSION=$(shell ./version.sh)
|
||||||
TARNAME=$(NAME)-$(VERSION).tar.gz
|
TARNAME=$(NAME)-$(VERSION).tar.gz
|
||||||
IMAGENAME=$(REPO)/$(NAME):$(VERSION)
|
IMAGENAME=$(REPO)/$(NAME):$(VERSION)
|
||||||
action="test-${PYMAIN}"
|
TEST_COMMAND=gitlab-runner exec docker --cache-dir=/tmp/gitlabrunner --docker-volumes /tmp/gitlabrunner:/tmp/gitlabrunner --env CI_PROJECT_NAME=$(NAME)
|
||||||
|
|
||||||
all: build run
|
all: build run
|
||||||
|
|
||||||
.FORCE:
|
FORCE:
|
||||||
|
|
||||||
version: .FORCE
|
version: FORCE
|
||||||
@echo $(VERSION) > $(NAME)/VERSION
|
@echo $(VERSION) > $(NAME)/VERSION
|
||||||
@echo $(VERSION)
|
@echo $(VERSION)
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ yapf:
|
|||||||
yapf -i -r senpy
|
yapf -i -r senpy
|
||||||
yapf -i -r tests
|
yapf -i -r tests
|
||||||
|
|
||||||
init:
|
dev:
|
||||||
pip install --user pre-commit
|
pip install --user pre-commit
|
||||||
pre-commit install
|
pre-commit install
|
||||||
|
|
||||||
@@ -34,27 +34,26 @@ quick_build: $(addprefix build-, $(PYMAIN))
|
|||||||
|
|
||||||
build: $(addprefix build-, $(PYVERSIONS))
|
build: $(addprefix build-, $(PYVERSIONS))
|
||||||
|
|
||||||
build-%: version Dockerfile-%
|
build-%: Dockerfile-%
|
||||||
docker build -t '$(IMAGENAME)-python$*' -f Dockerfile-$* .;
|
docker build -t '$(IMAGENAME)-python$*' -f Dockerfile-$* .;
|
||||||
|
|
||||||
quick_test: $(addprefix test-,$(PYMAIN))
|
quick_test: $(addprefix test-,$(PYMAIN))
|
||||||
|
|
||||||
dev-%:
|
test: $(addprefix test-,$(PYVERSIONS))
|
||||||
@docker start $(NAME)-dev || (\
|
|
||||||
|
debug-%:
|
||||||
|
@docker start $(NAME)-debug || (\
|
||||||
$(MAKE) build-$*; \
|
$(MAKE) build-$*; \
|
||||||
docker run -d -w /usr/src/app/ -v $$PWD:/usr/src/app --entrypoint=/bin/bash -p 5000:5000 -ti --name $(NAME)-dev '$(IMAGENAME)-python$*'; \
|
docker run -d -w /usr/src/app/ -v $$PWD:/usr/src/app --entrypoint=/bin/bash -p 5000:5000 -ti --name $(NAME)-debug '$(IMAGENAME)-python$*'; \
|
||||||
|
docker exec -ti $(NAME)-debug pip install -r test-requirements.txt; \
|
||||||
)\
|
)\
|
||||||
|
|
||||||
docker exec -ti $(NAME)-dev bash
|
docker attach $(NAME)-debug
|
||||||
|
|
||||||
dev: dev-$(PYMAIN)
|
debug: debug-$(PYMAIN)
|
||||||
|
|
||||||
test-all: $(addprefix test-,$(PYVERSIONS))
|
test-%:
|
||||||
|
$(TEST_COMMAND) test-$*
|
||||||
test-%: build-%
|
|
||||||
docker run --rm --entrypoint /usr/local/bin/python -w /usr/src/app $(IMAGENAME)-python$* setup.py test
|
|
||||||
|
|
||||||
test: test-$(PYMAIN)
|
|
||||||
|
|
||||||
dist/$(TARNAME):
|
dist/$(TARNAME):
|
||||||
docker run --rm -ti -v $$PWD:/usr/src/app/ -w /usr/src/app/ python:$(PYMAIN) python setup.py sdist;
|
docker run --rm -ti -v $$PWD:/usr/src/app/ -w /usr/src/app/ python:$(PYMAIN) python setup.py sdist;
|
||||||
@@ -78,7 +77,7 @@ upload: test $(addprefix upload-,$(PYVERSIONS))
|
|||||||
clean:
|
clean:
|
||||||
@docker ps -a | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1;}}' | xargs docker rm -v 2>/dev/null|| true
|
@docker ps -a | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1;}}' | xargs docker rm -v 2>/dev/null|| true
|
||||||
@docker images | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true
|
@docker images | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true
|
||||||
@docker rmi $(NAME)-dev 2>/dev/null || true
|
@docker rmi $(NAME)-debug 2>/dev/null || true
|
||||||
|
|
||||||
|
|
||||||
git_commit:
|
git_commit:
|
||||||
@@ -87,7 +86,7 @@ git_commit:
|
|||||||
git_tag:
|
git_tag:
|
||||||
git tag ${VERSION}
|
git tag ${VERSION}
|
||||||
|
|
||||||
git_push:
|
upload_git:
|
||||||
git push --tags origin master
|
git push --tags origin master
|
||||||
|
|
||||||
pip_upload:
|
pip_upload:
|
||||||
@@ -100,14 +99,4 @@ run-%: build-%
|
|||||||
|
|
||||||
run: run-$(PYMAIN)
|
run: run-$(PYMAIN)
|
||||||
|
|
||||||
push-latest: build-$(PYMAIN)
|
.PHONY: test test-% build-% build test pip_test run yapf dev
|
||||||
docker tag $(IMAGENAME)-python$(PYMAIN) $(IMAGENAME)
|
|
||||||
docker push $(IMAGENAME)
|
|
||||||
|
|
||||||
push-%: build-%
|
|
||||||
docker push $(IMAGENAME)-python$*
|
|
||||||
|
|
||||||
ci:
|
|
||||||
gitlab-runner exec docker --docker-volumes /var/run/docker.sock:/var/run/docker.sock --env CI_PROJECT_NAME=$(NAME) ${action}
|
|
||||||
|
|
||||||
.PHONY: test test-% test-all build-% build test pip_test run yapf dev ci version .FORCE
|
|
||||||
|
@@ -38,9 +38,9 @@ If you want to install senpy globally, use sudo instead of the ``--user`` flag.
|
|||||||
|
|
||||||
Docker Image
|
Docker Image
|
||||||
************
|
************
|
||||||
Build the image or use the pre-built one: ``docker run -ti -p 5000:5000 gsiupm/senpy --default-plugins``.
|
Build the image or use the pre-built one: ``docker run -ti -p 5000:5000 gsiupm/senpy --host 0.0.0.0 --default-plugins``.
|
||||||
|
|
||||||
To add custom plugins, add a volume and tell senpy where to find the plugins: ``docker run -ti -p 5000:5000 -v <PATH OF PLUGINS>:/plugins gsiupm/senpy --default-plugins -f /plugins``
|
To add custom plugins, add a volume and tell senpy where to find the plugins: ``docker run -ti -p 5000:5000 -v <PATH OF PLUGINS>:/plugins gsiupm/senpy --host 0.0.0.0 --default-plugins -f /plugins``
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
@@ -284,7 +284,7 @@ class Senpy(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate_info(cls, info):
|
def validate_info(cls, info):
|
||||||
return all(x in info for x in ('name', 'module', 'description', 'version'))
|
return all(x in info for x in ('name', 'module', 'version'))
|
||||||
|
|
||||||
def install_deps(self):
|
def install_deps(self):
|
||||||
for i in self.plugins.values():
|
for i in self.plugins.values():
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: Ekman2VAD
|
name: Ekman2VAD
|
||||||
module: ekman2vad
|
module: ekman2vad
|
||||||
description: Plugin to convert emotion sets from Ekman to VAD
|
description: Plugin to convert from Ekman to VAD
|
||||||
version: 0.1
|
version: 0.1
|
||||||
onyx:doesConversion:
|
onyx:doesConversion:
|
||||||
- onyx:conversionFrom: emoml:big6
|
- onyx:conversionFrom: emoml:big6
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
|
pytest
|
||||||
mock
|
mock
|
||||||
pytest-cov
|
pytest-cov
|
||||||
pytest
|
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
from unittest import TestCase
|
|
||||||
from senpy.api import parse_params, API_PARAMS, NIF_PARAMS, WEB_PARAMS
|
|
||||||
from senpy.models import Error
|
|
||||||
|
|
||||||
|
|
||||||
class APITest(TestCase):
|
|
||||||
|
|
||||||
def test_api_params(self):
|
|
||||||
"""The API should not define any required parameters without a default"""
|
|
||||||
parse_params({}, spec=API_PARAMS)
|
|
||||||
|
|
||||||
def test_web_params(self):
|
|
||||||
"""The WEB should not define any required parameters without a default"""
|
|
||||||
parse_params({}, spec=WEB_PARAMS)
|
|
||||||
|
|
||||||
def test_basic(self):
|
|
||||||
a = {}
|
|
||||||
try:
|
|
||||||
parse_params(a, spec=NIF_PARAMS)
|
|
||||||
raise AssertionError()
|
|
||||||
except Error:
|
|
||||||
pass
|
|
||||||
a = {'input': 'hello'}
|
|
||||||
p = parse_params(a, spec=NIF_PARAMS)
|
|
||||||
assert 'input' in p
|
|
||||||
b = {'i': 'hello'}
|
|
||||||
p = parse_params(b, spec=NIF_PARAMS)
|
|
||||||
assert 'input' in p
|
|
||||||
|
|
||||||
def test_plugin(self):
|
|
||||||
query = {}
|
|
||||||
plug_params = {
|
|
||||||
'hello': {
|
|
||||||
'aliases': ['hello', 'hiya'],
|
|
||||||
'required': True
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try:
|
|
||||||
parse_params(query, spec=plug_params)
|
|
||||||
raise AssertionError()
|
|
||||||
except Error:
|
|
||||||
pass
|
|
||||||
query['hello'] = 'world'
|
|
||||||
p = parse_params(query, spec=plug_params)
|
|
||||||
assert 'hello' in p
|
|
||||||
assert p['hello'] == 'world'
|
|
||||||
del query['hello']
|
|
||||||
|
|
||||||
query['hiya'] = 'dlrow'
|
|
||||||
p = parse_params(query, spec=plug_params)
|
|
||||||
assert 'hello' in p
|
|
||||||
assert 'hiya' in p
|
|
||||||
assert p['hello'] == 'dlrow'
|
|
||||||
|
|
||||||
def test_default(self):
|
|
||||||
spec = {
|
|
||||||
'hello': {
|
|
||||||
'required': True,
|
|
||||||
'default': 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p = parse_params({}, spec=spec)
|
|
||||||
assert 'hello' in p
|
|
||||||
assert p['hello'] == 1
|
|
@@ -42,7 +42,6 @@ class ExtensionsTest(TestCase):
|
|||||||
info = {
|
info = {
|
||||||
'name': 'TestPip',
|
'name': 'TestPip',
|
||||||
'module': 'dummy',
|
'module': 'dummy',
|
||||||
'description': None,
|
|
||||||
'requirements': ['noop'],
|
'requirements': ['noop'],
|
||||||
'version': 0
|
'version': 0
|
||||||
}
|
}
|
||||||
|
2
version.sh
Executable file
2
version.sh
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
git describe --long --tags --dirty
|
Reference in New Issue
Block a user