~ubuntu-branches/ubuntu/trusty/desktopcouch/trusty

« back to all changes in this revision

Viewing changes to desktopcouch/tests/test_start_local_couchdb.py

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine
  • Date: 2010-04-19 12:52:22 UTC
  • mfrom: (12.1.9 lucid)
  • Revision ID: james.westby@ubuntu.com-20100419125222-zsh9lrm15h84951j
* debian/patches/lp_522538.patch
  - Handle reconnects if the server isn't running (LP: #522538)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""testing desktopcouch/start_local_couchdb.py module"""
2
2
 
3
3
import testtools
4
 
import os, sys, shutil
 
4
import os, sys
5
5
import desktopcouch.tests as test_environment
6
6
import desktopcouch
7
7
sys.path.append(
74
74
        super(TestUpdateDesignDocuments, self).setUp()
75
75
        xdg_data = os.path.split(test_environment.test_context.db_dir)[0]
76
76
        try:
77
 
            shutil.rmtree(os.path.join(xdg_data, "desktop-couch"))
 
77
            os.mkdir(os.path.join(xdg_data, "desktop-couch"))
78
78
        except OSError:
79
 
            pass # don't worry if folder does not exist
80
 
        os.mkdir(os.path.join(xdg_data, "desktop-couch"))
 
79
            pass # don't worry if the folder already exists
81
80
        for d in DIRS:
82
81
            os.mkdir(os.path.join(xdg_data, "desktop-couch", d))
83
82
        for f, data in FILES.items():
137
136
        mocker.restore()
138
137
        mocker.verify()
139
138
 
140
 
    def test_pair_ubuntuone_with_sso(self):
141
 
        """ Test the pairing with ubuntu one.
142
 
        
143
 
        Ensure that the pair ubuntu one method is called when we do have
144
 
        credentials.
145
 
        """
146
 
        from desktopcouch.start_local_couchdb import update_pairing_service
147
 
        mocker = Mocker()
148
 
        sso_mock = mocker.mock()
149
 
        pair_ubuntu_one_mock = mocker.replace(
150
 
            'desktopcouch.pair.couchdb_pairing.' + 
151
 
            'ubuntuone_pairing.pair_with_ubuntuone')
152
 
        # make the sso credentials return a dictionary with fake data
153
 
        sso_mock.find_credentials('Ubuntu One')
154
 
        mocker.result({'fake':'credential'})
155
 
        pair_ubuntu_one_mock()
156
 
        mocker.replay()
157
 
        # call the start method to ensure that the methods are correctly called
158
 
        update_pairing_service(sso_mock)
159
 
        mocker.verify()
160
 
 
161
 
    def test_pair_ubuntuone_without_sso(self):
162
 
        """ Test the pairing with ubuntu one.
163
 
        
164
 
        Ensure that the pair ubuntu one method is called when we do have
165
 
        credentials.
166
 
        """
167
 
        from desktopcouch.start_local_couchdb import update_pairing_service
168
 
        mocker = Mocker()
169
 
        pair_ubuntu_one_mock = mocker.replace(
170
 
            'desktopcouch.pair.couchdb_pairing.' + 
171
 
            'ubuntuone_pairing.pair_with_ubuntuone')
172
 
        # make the sso credentials return a dictionary with fake data
173
 
        mocker.result({'fake':'credential'})
174
 
        # pair with ubuntu one never called!
175
 
        mocker.replay()
176
 
        # call the start method to ensure that the methods are correctly called
177
 
        update_pairing_service(sso=None, test_import_fails=True)
178
 
        mocker.verify()
179
139