Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brantley Harris committed Apr 17, 2010
1 parent 194c6e7 commit e0a011a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 0 additions & 1 deletion minister/service/fastcgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Service(base.Service):
### Instance Methods ###################
def init(self):
self._resource = FastCGI(address=self.address, filter=self.filter)
self.layout = Resource.create(self.layout)

def _proxy(self, environ, start_response):
self._resource(environ, start_response)
23 changes: 20 additions & 3 deletions minister/service/php.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
"""

import os, sys
import fastcgi
import fastcgi, base

from eventlet.green import socket
from minister.static import Static

class Service(fastcgi.Service):
class Service(fastcgi.Service, base.ProcessService):
type = 'php:service'
address = ('127.0.0.1', 0)
executable = 'php-cgi'
ini = None
options = {}
num_processes = 1
index = ('index.php', 'index.html')
port_range = (10000, 20000)

def init(self):
if (self.address[1] == 0):
Expand Down Expand Up @@ -76,4 +77,20 @@ def find_index(self, path):
candidate = os.path.join(path, i)
if os.path.isfile(candidate):
return candidate
return None
return None

_used_addresses = set()
def find_port(self):
host = self.address[0]
for port in range(*self.port_range):
if (host, port) in self._used_addresses:
continue
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind((host, port))
except socket.error, e:
continue
else:
self._used_addresses.add((host, port))
s.close()
return host, port
4 changes: 2 additions & 2 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUp(self):
services = [{'type': 'admin', 'path': '@admin', 'url': 'admin/', 'site': '*'}]
self.manager = Manager(path=self.repo_path, services=services, debug=True)
eventlet.spawn(self.manager.serve, ('', port))
eventlet.sleep(.03) #Give it some time to get on its feet.
eventlet.sleep(.3) #Give it some time to get on its feet.

def tearDown(self):
self.manager.close()
Expand Down Expand Up @@ -50,5 +50,5 @@ def test_b(self):
self.assertEqual(request.status, 404)

def test_d(self):
self.assertEqual(self.manager.get_service('d').status, 'mia')
self.assertEqual(self.manager.get_service('d').status, 'failed')

0 comments on commit e0a011a

Please sign in to comment.