Repository: grycap/RADL (language: python)

Issue:
description is not returned in str of RADL



Discussion / hints:

Fix patch:
diff --git a/radl/radl.py b/radl/radl.py
index 85957cc..77b7c94 100644
--- a/radl/radl.py
+++ b/radl/radl.py
@@ -1165,8 +1165,12 @@ def __init__(self):
         """List of contextualize."""
 
     def __str__(self):
-        return "\n".join([str(f) for fs in [self.ansible_hosts, self.networks, self.systems, self.configures,
+        res = ""
+        if self.description:
+            res = str(self.description) + "\n"
+        res += "\n".join([str(f) for fs in [self.ansible_hosts, self.networks, self.systems, self.configures,
                                             [self.contextualize], self.deploys] for f in fs])
+        return res
 
     def add(self, aspect, ifpresent="error"):
         """
@@ -1514,3 +1518,6 @@ def __init__(self, name, features=None, reference=False, line=None):
         """True if it is only a reference and it isn't a definition."""
         Features.__init__(self, features)
         self.line = line
+
+    def __str__(self):
+        return "description %s (%s)" % (self.id, Features.__str__(self))


Test patch:
diff --git a/test/TestRADL.py b/test/TestRADL.py
index 3127834..b093486 100644
--- a/test/TestRADL.py
+++ b/test/TestRADL.py
@@ -443,7 +443,6 @@ def test_description(self):
         self.assertEqual(r.description.getValue("long"), "long desc")
 
         radl_json = dump_radl_json(r)
-        print(radl_json)
         r = parse_radl_json(radl_json)
         r.check()
         self.assertEqual(r.description.getValue("long"), "long desc")