mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-23 10:02:21 +00:00
Added CLI and refactored argument parsing
This commit is contained in:
@@ -5,10 +5,6 @@ from time import sleep
|
||||
|
||||
class SleepPlugin(SenpyPlugin):
|
||||
|
||||
def __init__(self, info, *args, **kwargs):
|
||||
super(SleepPlugin, self).__init__(info, *args, **kwargs)
|
||||
self.timeout = int(info["timeout"])
|
||||
|
||||
def activate(self, *args, **kwargs):
|
||||
sleep(self.timeout)
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"description": "I am dummy",
|
||||
"author": "@balkian",
|
||||
"version": "0.1",
|
||||
"timeout": "2",
|
||||
"timeout": 0.5,
|
||||
"extra_params": {
|
||||
"timeout": {
|
||||
"@id": "timeout_sleep",
|
||||
|
@@ -61,7 +61,7 @@ class BlueprintsTest(TestCase):
|
||||
|
||||
def test_headers(self):
|
||||
for i, j in product(["/api/plugins/?nothing=", "/api/?i=test&"],
|
||||
["headers", "inHeaders"]):
|
||||
["inHeaders"]):
|
||||
resp = self.client.get("%s" % (i))
|
||||
assert "@context" in resp.json
|
||||
resp = self.client.get("%s&%s=0" % (i, j))
|
||||
|
21
tests/test_cli.py
Normal file
21
tests/test_cli.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from unittest import TestCase
|
||||
from senpy.cli import main_function
|
||||
from senpy.models import Error
|
||||
|
||||
|
||||
class CLITest(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
self.assertRaises(Error, partial(main_function, []))
|
||||
res = main_function(['--input', 'test'])
|
||||
assert 'entries' in res
|
||||
res = main_function(['--input', 'test', '--algo', 'rand'])
|
||||
assert 'entries' in res
|
||||
assert 'analysis' in res
|
||||
assert res['analysis'][0]['name'] == 'rand'
|
Reference in New Issue
Block a user