Skip to content
Browse files

Merge branch 'tests_for_max' of git://github.com/ctb/pony-build into env

  • Loading branch information...
2 parents ae40d55 + 5b1cd5e commit a6ef0eb91efe790f3473644b0e79b2c128237100 @mlaite mlaite committed Apr 20, 2010
Showing with 50 additions and 0 deletions.
  1. +50 −0 client/test_client/test_context.py
View
50 client/test_client/test_context.py
@@ -0,0 +1,50 @@
+from pony_client import Context, BaseCommand, do
+import pony_client
+
+class StubCommand(BaseCommand):
+ command_name = 'test command'
+ def __init__(self):
+ BaseCommand.__init__(self, [])
+
+ def run(self, context):
+ self.output = 'some output'
+ self.errout = 'some errout'
+ self.duration = 0.
+
+class SuccessfulCommand(StubCommand):
+ command_type = 'forced_success'
+ def run(self, context):
+ self.status = 0
+
+class FailedCommand(StubCommand):
+ command_type = 'forced_failure'
+ def run(self, context):
+ self.status = -1
+
+class ExceptedCommand(StubCommand):
+ command_type = 'forced_exception'
+ def run(self, context):
+ raise Exception("I suck")
+
+class FailedContextInit(Context):
+ def __init__(self, *args, **kwargs):
+ Context.__init__(self, *args, **kwargs)
+ pony_client.error_state = True
+
+def test_context_failure():
+ c = FailedContextInit()
+
+ (client_info, _, _) = do('foo', [ SuccessfulCommand() ], context=c)
+ assert not client_info['success']
+
+def test_failed_command():
+ c = Context()
+
+ (client_info, _, _) = do('foo', [ FailedCommand() ], context=c)
+ assert not client_info['success']
+
+def test_exception_command():
+ c = Context()
+
+ (client_info, _, _) = do('foo', [ ExceptedCommand() ], context=c)
+ assert not client_info['success']

0 comments on commit a6ef0eb

Please sign in to comment.
Something went wrong with that request. Please try again.