core: better error on export of internal type
more descriptive error when trying to export OrType, NoneOr, ValueType and DataTypeType Change-Id: If13815e9d2b177042b24a1bb62b1ad1d1d88b502 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32737 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
parent
010f0747e1
commit
5358412b7a
@ -90,7 +90,11 @@ class DataType(HasProperties):
|
||||
|
||||
def export_datatype(self):
|
||||
"""return a python object which after jsonifying identifies this datatype"""
|
||||
raise NotImplementedError
|
||||
raise ProgrammingError(
|
||||
f"{type(self).__name__} is not able to be exported to SECoP. "
|
||||
f"It is intended for internal use only."
|
||||
)
|
||||
|
||||
|
||||
def export_value(self, value):
|
||||
"""if needed, reformat value for transport"""
|
||||
@ -1232,6 +1236,7 @@ class OrType(DataType):
|
||||
self.types = types
|
||||
self.default = self.types[0].default
|
||||
|
||||
|
||||
def __call__(self, value):
|
||||
"""accepts any of the given types, takes the first valid"""
|
||||
for t in self.types:
|
||||
|
@ -41,7 +41,7 @@ def copytest(dt):
|
||||
|
||||
def test_DataType():
|
||||
dt = DataType()
|
||||
with pytest.raises(NotImplementedError):
|
||||
with pytest.raises(ProgrammingError):
|
||||
dt.export_datatype()
|
||||
with pytest.raises(NotImplementedError):
|
||||
dt('')
|
||||
|
Loading…
x
Reference in New Issue
Block a user