Commit 997cf059 authored by Samuel GAIST's avatar Samuel GAIST

[plotterparameter] Fix writing

The write method was wrong as well as there were missing
pieces in the class for it to work properly.
parent 8a79b938
Pipeline #29919 passed with stage
in 15 minutes and 57 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)
"plotter": "plot/unknown/1",
"description": "",
"data": {}
"plotter": "plot/unknown/1",
"description": "",
"data": {}
......@@ -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))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment