summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-01-10 15:39:42 -0200
committerdrebs <drebs@leap.se>2013-01-10 15:39:42 -0200
commit7322237cc907cb762dbcfdd9f561a5c2c42aa8df (patch)
treeabf22d5128812aece784e0deab7b0b6974461c01
parentc8a36f42038a197d22cd8a13a9be4f93c9310068 (diff)
LeapDatabase passes u1db TestHTTPDatabaseSimpleOperations.
-rw-r--r--tests/test_leap_backend.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/test_leap_backend.py b/tests/test_leap_backend.py
index 4491fe86..1759faad 100644
--- a/tests/test_leap_backend.py
+++ b/tests/test_leap_backend.py
@@ -11,8 +11,9 @@ import testscenarios
from leap.soledad.backends import leap_backend
from leap.soledad.tests import u1db_tests as tests
from leap.soledad.tests.u1db_tests.test_remote_sync_target import make_http_app
-from leap.soledad.tests.u1db_tests.test_backends import (
- AllDatabaseTests,
+from leap.soledad.tests.u1db_tests.test_backends import AllDatabaseTests
+from leap.soledad.tests.u1db_tests.test_http_database import (
+ TestHTTPDatabaseSimpleOperations,
)
@@ -70,4 +71,34 @@ class LeapTests(AllDatabaseTests):
scenarios = LEAP_SCENARIOS
+#-----------------------------------------------------------------------------
+# The following tests come from `u1db.tests.test_http_client`.
+#-----------------------------------------------------------------------------
+
+class TestLeapDatabaseSimpleOperations(TestHTTPDatabaseSimpleOperations):
+
+ def setUp(self):
+ super(TestHTTPDatabaseSimpleOperations, self).setUp()
+ self.db = leap_backend.LeapDatabase('dbase')
+ self.db._conn = object() # crash if used
+ self.got = None
+ self.response_val = None
+
+ def _request(method, url_parts, params=None, body=None,
+ content_type=None):
+ self.got = method, url_parts, params, body, content_type
+ if isinstance(self.response_val, Exception):
+ raise self.response_val
+ return self.response_val
+
+ def _request_json(method, url_parts, params=None, body=None,
+ content_type=None):
+ self.got = method, url_parts, params, body, content_type
+ if isinstance(self.response_val, Exception):
+ raise self.response_val
+ return self.response_val
+
+ self.db._request = _request
+ self.db._request_json = _request_json
+
load_tests = tests.load_with_scenarios