From 17c3c2d2d18abac6f63f82beed9ccc875f2b16af Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 10 Jan 2013 15:39:42 -0200 Subject: LeapDatabase passes u1db TestHTTPDatabaseSimpleOperations. --- src/leap/soledad/tests/test_leap_backend.py | 35 +++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/leap') diff --git a/src/leap/soledad/tests/test_leap_backend.py b/src/leap/soledad/tests/test_leap_backend.py index 4491fe86..1759faad 100644 --- a/src/leap/soledad/tests/test_leap_backend.py +++ b/src/leap/soledad/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 -- cgit v1.2.3