Commit 58489f6d authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

Merge branch '78_fix_plotterparameter' into 'master'

Fix plotterparameter writing

Closes #78

See merge request !73
parents 8a79b938 997cf059
Pipeline #29921 passed with stages
in 21 minutes and 3 seconds
......@@ -42,6 +42,8 @@ plotterparameter
Validation for plotterparameters
import simplejson as json
from . import schema
from . import prototypes
from . import utils
......@@ -241,6 +243,16 @@ class Plotterparameter(object):
self._name = value = Storage(self.prefix, value)
def description(self):
"""The short description for this object"""
return"description", None)
def description(self, value):
"""Sets the short description for this object"""["description"] = value
def documentation(self):
"""The full-length description for this object"""
......@@ -272,6 +284,27 @@ class Plotterparameter(object):
def json_dumps(self, indent=4):
"""Dumps the JSON declaration of this object in a string
indent (int): The number of indentation spaces at every indentation
str: The JSON representation for this object
return json.dumps(, indent=indent, cls=utils.NumpyJSONEncoder)
def __str__(self):
return self.json_dumps()
def write(self, storage=None):
"""Writes contents to prefix location
......@@ -287,4 +320,4 @@ class Plotterparameter(object):
raise RuntimeError("plotterparameter has no name")
storage = # overwrite, self.code, self.description), self.description)
......@@ -35,27 +35,52 @@
from . import prefix
from ..plotterparameter import Plotterparameter
from ..plotterparameter import Storage
from . import prefix
def test_default():
# test for the "dummy" plotterparameter
p = Plotterparameter(prefix, data=None)
def test_plot_config_1():
# test for a simple plotterparameter for a simple plotter
p = Plotterparameter(prefix, "plot/config/1"), "\n * %s" % "\n * ".join(p.errors))
def test_plot_invalid_1():
# test for invalid parameter name
p = Plotterparameter(prefix, "plot/invalid/1")[0] == "'not_an_option' isn't a parameter for plotter user/scatter/1")
p.errors[0] == "'not_an_option' isn't a parameter for plotter user/scatter/1"
def test_plot_invalid_2():
# test for invalid "plotter" field
p = Plotterparameter(prefix, "plot/invalid/2")[0] == "Plotter declaration file not found: user/not_a_plotter/1")
p.errors[0] == "Plotter declaration file not found: user/not_a_plotter/1"
def test_export():
plotterparameter_name = "plot/config/1"
target_name = "plot/generated/1"
obj = Plotterparameter(prefix, plotterparameter_name), "\n * %s" % "\n * ".join(obj.errors))
pp_storage = Storage(prefix, target_name)
# load from tmp_prefix and validates
exported = Plotterparameter(prefix, target_name), "\n * %s" % "\n * ".join(exported.errors))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment