summaryrefslogtreecommitdiff
path: root/common/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/leap')
-rw-r--r--common/src/leap/soledad/common/couch.py2
-rw-r--r--common/src/leap/soledad/common/tests/test_couch.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/common/src/leap/soledad/common/couch.py b/common/src/leap/soledad/common/couch.py
index cd5185eb..36f6239e 100644
--- a/common/src/leap/soledad/common/couch.py
+++ b/common/src/leap/soledad/common/couch.py
@@ -1447,6 +1447,8 @@ class CouchServerState(ServerState):
Exit code: %d
""" % (dbname, self.create_cmd, out, code))
raise Unauthorized()
+ db = self.open_database(dbname)
+ return db, db.replica_uid
def delete_database(self, dbname):
"""
diff --git a/common/src/leap/soledad/common/tests/test_couch.py b/common/src/leap/soledad/common/tests/test_couch.py
index d0a9dc3c..a56cea21 100644
--- a/common/src/leap/soledad/common/tests/test_couch.py
+++ b/common/src/leap/soledad/common/tests/test_couch.py
@@ -29,6 +29,7 @@ from uuid import uuid4
from testscenarios import TestWithScenarios
from twisted.trial import unittest
+from mock import Mock
from u1db import errors as u1db_errors
from u1db import SyncTarget
@@ -1512,7 +1513,12 @@ class CommandBasedDBCreationTest(unittest.TestCase):
def test_ensure_db_using_custom_command(self):
state = couch.CouchServerState("url", create_cmd="echo")
- state.ensure_database("user-1337") # works
+ mock_db = Mock()
+ mock_db.replica_uid = 'replica_uid'
+ state.open_database = Mock(return_value=mock_db)
+ db, replica_uid = state.ensure_database("user-1337") # works
+ self.assertEquals(mock_db, db)
+ self.assertEquals(mock_db.replica_uid, replica_uid)
def test_raises_unauthorized_on_failure(self):
state = couch.CouchServerState("url", create_cmd="inexistent")