Skip to content

Commit

Permalink
Add __str__ method to various subclasses of Task.
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed Jun 9, 2015
1 parent 40a2d5b commit eaa6e29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions blivet/tasks/task.py
Expand Up @@ -71,6 +71,9 @@ def _availabilityErrors(self):

dependsOn = []

def __str__(self):
return "unimplemented task"

def doTask(self, *args, **kwargs):
raise NotImplementedError()

Expand All @@ -82,6 +85,9 @@ class BasicApplication(Task):

# TASK methods

def __str__(self):
return str(self.ext)

@property
def _availabilityErrors(self):
errors = self.ext.availabilityErrors
Expand Down
7 changes: 7 additions & 0 deletions tests/tasks_test/basic_tests.py
Expand Up @@ -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))

0 comments on commit eaa6e29

Please sign in to comment.