diff options
author | Bruno Wagner <bwgpro@gmail.com> | 2015-08-05 16:57:17 -0300 |
---|---|---|
committer | Bruno Wagner <bwgpro@gmail.com> | 2015-08-05 16:59:05 -0300 |
commit | 45c684100ffc611509b76549fbb2b93f2d21e41b (patch) | |
tree | fbd1606d92da7526c1b39998b6b8503713027193 /common/src/leap | |
parent | 66f07534a611056214e4f8b02e0143944b816c39 (diff) |
[tests] Fixed remaining parse tests
All the response parse tests are passing now, response
with no entries was broken because it wasn't being treated
and the others were broken because of calls that no longer
existed
Diffstat (limited to 'common/src/leap')
-rw-r--r-- | common/src/leap/soledad/common/tests/test_sync_target.py | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/common/src/leap/soledad/common/tests/test_sync_target.py b/common/src/leap/soledad/common/tests/test_sync_target.py index 070ead3e..21ead889 100644 --- a/common/src/leap/soledad/common/tests/test_sync_target.py +++ b/common/src/leap/soledad/common/tests/test_sync_target.py @@ -56,7 +56,7 @@ from leap.soledad.common.tests.u1db_tests import test_sync # The following tests come from `u1db.tests.test_remote_sync_target`. # ----------------------------------------------------------------------------- -class TestSoledadParsingSyncStream( +class TestSoledadParseReceivedDocResponse( test_remote_sync_target.TestParsingSyncStream, BaseSoledadTest): @@ -112,49 +112,40 @@ class TestSoledadParsingSyncStream( self.target._parse_received_doc_response("") def test_wrong_end(self): - tgt = target.SoledadHTTPSyncTarget("http://foo/foo") - - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, "[\r\n{}", None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response("[\r\n{}") - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, "[\r\n", None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response("[\r\n") def test_missing_comma(self): - tgt = target.SoledadHTTPSyncTarget("http://foo/foo") - - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, - '[\r\n{}\r\n{"id": "i", "rev": "r", ' - '"content": "c", "gen": 3}\r\n]', None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response( + '[\r\n{}\r\n{"id": "i", "rev": "r", ' + '"content": "c", "gen": 3}\r\n]') def test_no_entries(self): - tgt = target.SoledadHTTPSyncTarget("http://foo/foo") - - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, "[\r\n]", None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response("[\r\n]") def test_error_in_stream(self): - tgt = target.SoledadHTTPSyncTarget("http://foo/foo") - - self.assertRaises(u1db.errors.Unavailable, - tgt._parse_sync_stream, - '[\r\n{"new_generation": 0},' - '\r\n{"error": "unavailable"}\r\n', None) - - self.assertRaises(u1db.errors.Unavailable, - tgt._parse_sync_stream, - '[\r\n{"error": "unavailable"}\r\n', None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response( + '[\r\n{"new_generation": 0},' + '\r\n{"error": "unavailable"}\r\n') - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, - '[\r\n{"error": "?"}\r\n', None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response( + '[\r\n{"error": "unavailable"}\r\n') + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response('[\r\n{"error": "?"}\r\n') # # functions for TestRemoteSyncTargets # + def make_local_db_and_soledad_target(test, path='test'): test.startServer() db = test.request_state._create_database(os.path.basename(path)) |