~ubuntu-branches/debian/squeeze/desktopcouch/squeeze

« back to all changes in this revision

Viewing changes to desktopcouch/tests/test_start_local_couchdb.py

  • Committer: Bazaar Package Importer
  • Author(s): David Paleino
  • Date: 2010-03-04 19:11:48 UTC
  • mfrom: (1.5.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100304191148-zcwp3rffruwkalvc
Tags: 0.6.2-1
* New upstream version
* debian/patches/01-use_simplejson.patch removed, better handled
  upstream (simplejson for py2.5 and json for py2.6)
* debian/rules: chmod desktop-stop to 755, since it's intended as
  an executable script
* debian/control: bump debhelper dependency to >= 7.0.50~ to use
  overridden rules in debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
import testtools
4
4
import os, sys
5
 
from desktopcouch.tests import xdg_data
 
5
import desktopcouch.tests as test_environment
6
6
import desktopcouch
7
7
sys.path.append(
8
8
    os.path.join(os.path.split(desktopcouch.__file__)[0], "..", "contrib"))
71
71
 
72
72
    def setUp(self):
73
73
        # create temp folder with databases and design documents in
 
74
        super(TestUpdateDesignDocuments, self).setUp()
 
75
        xdg_data = os.path.split(test_environment.test_context.db_dir)[0]
74
76
        try:
75
77
            os.mkdir(os.path.join(xdg_data, "desktop-couch"))
76
78
        except OSError:
90
92
        couchdb = mocker.replace("desktopcouch.records.server.CouchDatabase")
91
93
 
92
94
        # databases that should be created
93
 
        couchdb("cfg", create=True)
94
 
        couchdb("cfg_and_empty_design", create=True)
95
 
        couchdb("cfg_and_design_no_views", create=True)
96
 
        couchdb("cfg_and_design_one_view_no_map", create=True)
97
 
        couchdb("cfg_and_design_one_view_map_no_reduce", create=True)
 
95
        couchdb("cfg", create=True, ctx=test_environment.test_context)
 
96
        couchdb(
 
97
            "cfg_and_empty_design", create=True,
 
98
            ctx=test_environment.test_context)
 
99
        couchdb(
 
100
            "cfg_and_design_no_views", create=True,
 
101
            ctx=test_environment.test_context)
 
102
        couchdb(
 
103
            "cfg_and_design_one_view_no_map", create=True,
 
104
            ctx=test_environment.test_context)
 
105
        couchdb(
 
106
            "cfg_and_design_one_view_map_no_reduce", create=True,
 
107
            ctx=test_environment.test_context)
 
108
 
98
109
        dbmock1 = mocker.mock()
99
110
        mocker.result(dbmock1)
100
111
        dbmock1.add_view("view1", "cfg_and_design_one_view_map_no_reduce:map",
101
112
          None, "doc1")
102
 
        couchdb("cfg_and_design_one_view_map_reduce", create=True)
 
113
        couchdb(
 
114
            "cfg_and_design_one_view_map_reduce", create=True,
 
115
            ctx=test_environment.test_context)
103
116
        dbmock2 = mocker.mock()
104
117
        mocker.result(dbmock2)
105
118
        dbmock2.add_view("view1", "cfg_and_design_one_view_map_reduce:map",
106
119
          "cfg_and_design_one_view_map_reduce:reduce", "doc1")
107
 
        couchdb("cfg_and_design_two_views_map_reduce", create=True)
 
120
        couchdb(
 
121
            "cfg_and_design_two_views_map_reduce", create=True,
 
122
            ctx=test_environment.test_context)
108
123
        dbmock3 = mocker.mock()
109
124
        mocker.result(dbmock3)
110
125
        dbmock3.add_view("view1", "cfg_and_design_two_views_map_reduce:map1",
116
131
        # all the right things
117
132
        mocker.replay()
118
133
        from desktopcouch.start_local_couchdb import update_design_documents
119
 
        update_design_documents()
 
134
        update_design_documents(ctx=test_environment.test_context)
120
135
 
121
136
        mocker.restore()
122
137
        mocker.verify()