changeset 403:b187f0894838

Fix build master unit tests broken in [449].
author cmlenz
date Fri, 03 Aug 2007 15:32:37 +0000
parents 08801667f00f
children 0bd6243b350c
files bitten/build/pythontools.py bitten/tests/master.py
diffstat 2 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/pythontools.py
+++ b/bitten/build/pythontools.py
@@ -16,6 +16,7 @@
     set
 except NameError:
     from sets import Set as set
+import shlex
 import sys
 
 from bitten.build import CommandLine, FileSet
@@ -35,15 +36,23 @@
         return python_path
     return sys.executable
 
-def distutils(ctxt, file_='setup.py', command='build'):
+def distutils(ctxt, file_='setup.py', command='build', options=None):
     """Execute a C{distutils} command.
     
     @param ctxt: the build context
     @type ctxt: an instance of L{bitten.recipe.Context}
     @param file_: name of the file defining the distutils setup
     @param command: the setup command to execute
+    @param options: additional options to pass to the command
     """
-    cmdline = CommandLine(_python_path(ctxt), [ctxt.resolve(file_), command],
+    if options:
+        if isinstance(options, basestring):
+            options = shlex.split(args)
+    else:
+        options = []
+
+    cmdline = CommandLine(_python_path(ctxt),
+                          [ctxt.resolve(file_), command] + options,
                           cwd=ctxt.basedir)
     log_elem = xmlio.Fragment()
     error_logged = False
--- a/bitten/tests/master.py
+++ b/bitten/tests/master.py
@@ -245,7 +245,8 @@
         outbody = StringIO()
         req = Mock(method='POST', base_path='',
                    path_info='/builds/%d/steps/' % build.id,
-                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
+                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
+                   remote_addr='127.0.0.1', args={},
                    perm=PermissionCache(self.env, 'hal'),
                    read=inbody.read,
                    send_response=lambda x: outheaders.setdefault('Status', x),
@@ -257,7 +258,7 @@
             module.process_request(req)
             self.fail('Expected RequestDone')
         except RequestDone:
-            self.assertEqual(200, outheaders['Status'])
+            self.assertEqual(201, outheaders['Status'])
             self.assertEqual('20', outheaders['Content-Length'])
             self.assertEqual('text/plain', outheaders['Content-Type'])
             self.assertEqual('Build step processed', outbody.getvalue())
@@ -295,7 +296,8 @@
         outbody = StringIO()
         req = Mock(method='POST', base_path='',
                    path_info='/builds/%d/steps/' % build.id,
-                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
+                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
+                   remote_addr='127.0.0.1', args={},
                    perm=PermissionCache(self.env, 'hal'),
                    read=inbody.read,
                    send_response=lambda x: outheaders.setdefault('Status', x),
@@ -307,7 +309,7 @@
             module.process_request(req)
             self.fail('Expected RequestDone')
         except RequestDone:
-            self.assertEqual(200, outheaders['Status'])
+            self.assertEqual(201, outheaders['Status'])
             self.assertEqual('20', outheaders['Content-Length'])
             self.assertEqual('text/plain', outheaders['Content-Type'])
             self.assertEqual('Build step processed', outbody.getvalue())
@@ -355,7 +357,8 @@
         outbody = StringIO()
         req = Mock(method='POST', base_path='',
                    path_info='/builds/%d/steps/' % build.id,
-                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
+                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
+                   remote_addr='127.0.0.1', args={},
                    perm=PermissionCache(self.env, 'hal'),
                    read=inbody.read,
                    send_response=lambda x: outheaders.setdefault('Status', x),
@@ -367,7 +370,7 @@
             module.process_request(req)
             self.fail('Expected RequestDone')
         except RequestDone:
-            self.assertEqual(200, outheaders['Status'])
+            self.assertEqual(201, outheaders['Status'])
             self.assertEqual('20', outheaders['Content-Length'])
             self.assertEqual('text/plain', outheaders['Content-Type'])
             self.assertEqual('Build step processed', outbody.getvalue())
@@ -414,7 +417,8 @@
         outbody = StringIO()
         req = Mock(method='POST', base_path='',
                    path_info='/builds/%d/steps/' % build.id,
-                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
+                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
+                   remote_addr='127.0.0.1', args={},
                    perm=PermissionCache(self.env, 'hal'),
                    read=inbody.read,
                    send_response=lambda x: outheaders.setdefault('Status', x),
@@ -426,7 +430,7 @@
             module.process_request(req)
             self.fail('Expected RequestDone')
         except RequestDone:
-            self.assertEqual(200, outheaders['Status'])
+            self.assertEqual(201, outheaders['Status'])
             self.assertEqual('20', outheaders['Content-Length'])
             self.assertEqual('text/plain', outheaders['Content-Type'])
             self.assertEqual('Build step processed', outbody.getvalue())
@@ -460,7 +464,8 @@
         outbody = StringIO()
         req = Mock(method='POST', base_path='',
                    path_info='/builds/%d/steps/' % build.id,
-                   href=Href('/trac'), remote_addr='127.0.0.1', args={},
+                   href=Href('/trac'), abs_href=Href('http://example.org/trac'),
+                   remote_addr='127.0.0.1', args={},
                    perm=PermissionCache(self.env, 'hal'),
                    read=inbody.read,
                    send_response=lambda x: outheaders.setdefault('Status', x),
@@ -472,7 +477,7 @@
             module.process_request(req)
             self.fail('Expected RequestDone')
         except RequestDone:
-            self.assertEqual(200, outheaders['Status'])
+            self.assertEqual(201, outheaders['Status'])
             self.assertEqual('20', outheaders['Content-Length'])
             self.assertEqual('text/plain', outheaders['Content-Type'])
             self.assertEqual('Build step processed', outbody.getvalue())
Copyright (C) 2012-2017 Edgewall Software