Skip to content
Snippets Groups Projects
Commit 2b2d84e8 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Merge branch '64_add_protocoltemplate_prototype' into 'master'

Implement support for protocol template prototype

See merge request !71
parents 1a1a8c49 6735c859
No related branches found
No related tags found
1 merge request!71Implement support for protocol template prototype
Pipeline #29849 passed
......@@ -48,6 +48,7 @@ Forward importing from :py:mod:`beat.backend.python.protocoltemplate`:
import six
from . import schema
from . import prototypes
from beat.backend.python.protocoltemplate import Storage
from beat.backend.python.protocoltemplate import (
......@@ -106,18 +107,22 @@ class ProtocolTemplate(BackendProtocolTemplate):
self.storage = None
self.dataformats = {} # preloaded dataformats
if isinstance(data, six.string_types): # user has passed a file pointer
self._name = data
self.storage = Storage(self.prefix, self._name)
data = self.storage.json.path
if not self.storage.json.exists():
self.errors.append(
"Protocol template declaration file not found: %s" % data
)
return
# this runs basic validation, including JSON loading if required
self.data, self.errors = schema.validate("protocoltemplate", data)
if self.errors:
return # don't proceed with the rest of validation
if data is None: # loads prototype and validates it
self.data, self.errors = prototypes.load("protocoltemplate")
assert not self.errors, "\n * %s" % "\n *".join(self.errors) # nosec
else:
if isinstance(data, six.string_types): # user has passed a file pointer
self._name = data
self.storage = Storage(self.prefix, self._name)
data = self.storage.json.path
if not self.storage.json.exists():
self.errors.append(
"Protocol template declaration file not found: %s" % data
)
return
# this runs basic validation, including JSON loading if required
self.data, self.errors = schema.validate("protocoltemplate", data)
if self.errors:
return # don't proceed with the rest of validation
{
"schema_version": 1,
"sets": [
{
"name": "name",
"outputs": {
"out": "user/single_integer/1"
}
}
]
}
......@@ -41,6 +41,12 @@ from . import prefix, tmp_prefix
from .utils import cleanup
def test_default():
obj = ProtocolTemplate(prefix, data=None)
nose.tools.assert_true(obj.valid, "\n * %s" % "\n * ".join(obj.errors))
def test_export():
for protocol_name in [
"double",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment