[master 3/3] Add __str__ method to various subclasses of Task.

mulkieran installerbot-noreply at redhat.com
Tue Jun 9 21:15:21 UTC 2015


From: mulhern <amulhern at redhat.com>

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/tasks/task.py            | 6 ++++++
 tests/tasks_test/basic_tests.py | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/blivet/tasks/task.py b/blivet/tasks/task.py
index 31e8dd4..61a8ae2 100644
--- a/blivet/tasks/task.py
+++ b/blivet/tasks/task.py
@@ -71,6 +71,9 @@ def _availabilityErrors(self):
 
     dependsOn = []
 
+    def __str__(self):
+        return "unimplemented task"
+
     def doTask(self, *args, **kwargs):
         raise NotImplementedError()
 
@@ -82,6 +85,9 @@ class BasicApplication(Task):
 
     # TASK methods
 
+    def __str__(self):
+        return str(self.ext)
+
     @property
     def _availabilityErrors(self):
         errors = self.ext.availabilityErrors
diff --git a/tests/tasks_test/basic_tests.py b/tests/tasks_test/basic_tests.py
index 3814973..3aa5492 100644
--- a/tests/tasks_test/basic_tests.py
+++ b/tests/tasks_test/basic_tests.py
@@ -38,3 +38,10 @@ def testAvailability(self):
         available_app = BasicAvailableApplication()
         self.assertTrue(available_app.available)
         self.assertEqual(available_app.availabilityErrors, [])
+
+    def testNames(self):
+        # Every basic application takes its string representation from
+        # the external resource.
+        unavailable_app = BasicUnavailableApplication()
+        self.assertTrue(isinstance(unavailable_app, task.BasicApplication))
+        self.assertEqual(str(unavailable_app), str(unavailable_app.ext))


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/eaa6e2947807062fb73378141e8734cea8f5ff0a


More information about the anaconda-patches mailing list