~james-w/desktopcouch/0.4.1

« back to all changes in this revision

Viewing changes to desktopcouch/records/tests/__init__.py

  • Committer: Ken VanDine
  • Date: 2009-09-23 18:23:42 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: ken.vandine@canonical.com-20090923182342-5rr1sdr8e9gyyxpt
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with desktopcouch.  If not, see <http://www.gnu.org/licenses/>.
16
16
"""Tests for Documents API"""
17
17
 
18
 
import os, tempfile, time, urllib2
19
 
from desktopcouch import local_files
20
 
from desktopcouch.start_local_couchdb import create_ini_file, run_couchdb
21
 
 
22
 
directory = tempfile.mkdtemp()
23
 
local_files.FILE_INI = os.path.join(directory, "test_couchdb.ini")
24
 
local_files.FILE_LOG = os.path.join(directory, "test_couchdb.log")
25
 
local_files.FILE_PID = os.path.join(directory, "test_couchdb.pid")
26
 
local_files.FILE_STDOUT = os.path.join(directory, "test_couchdb.stdout")
27
 
local_files.FILE_STDERR = os.path.join(directory, "test_couchdb.stderr")
28
 
 
29
 
local_files.DIR_DB = os.path.join(directory, "test_couchdb")
30
 
os.mkdir(local_files.DIR_DB)
31
 
 
32
 
PORT = "21224"
33
 
create_ini_file(port=PORT)
34
 
local_files.COUCH_EXEC_COMMAND = [
35
 
    local_files.COUCH_EXE, local_files.couch_chain_flag(), local_files.FILE_INI,
36
 
    '-p', local_files.FILE_PID, '-o', local_files.FILE_STDOUT, '-e',
37
 
    local_files.FILE_STDERR]
38
 
run_couchdb()
39
 
 
40
 
def get_uri():
41
 
    uri = 'http://localhost:%s' % PORT
42
 
    i = 0
43
 
    while i < 100:
44
 
        try:
45
 
            urllib2.urlopen(uri)
46
 
            break
47
 
        except:
48
 
            time.sleep(0.1)
49
 
        i += 1
50
 
    return uri