diff options
author | Bruno Wagner <bwgpro@gmail.com> | 2015-08-05 16:43:19 -0300 |
---|---|---|
committer | Bruno Wagner <bwgpro@gmail.com> | 2015-08-05 16:45:37 -0300 |
commit | 66f07534a611056214e4f8b02e0143944b816c39 (patch) | |
tree | 88b348108da79fa6bdbafba493483015a09c6e9d /common/src/leap/soledad | |
parent | 2824858b15b3dc10737ce2cc159bbe8d955bdaa5 (diff) |
[tests] Created a setup for the http target tests
Created a setup for the http target tests
Fixed two tests relying on http target that were
outdated
Fixed a call for an exception that doesn't exist, it
won't break anymore if it gets to that exception
Diffstat (limited to 'common/src/leap/soledad')
-rw-r--r-- | common/src/leap/soledad/common/tests/test_sync_target.py | 45 |
1 files changed, 27 insertions, 18 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 be765152..070ead3e 100644 --- a/common/src/leap/soledad/common/tests/test_sync_target.py +++ b/common/src/leap/soledad/common/tests/test_sync_target.py @@ -65,6 +65,19 @@ class TestSoledadParsingSyncStream( target. """ + def setUp(self): + super(test_remote_sync_target.TestParsingSyncStream, self).setUp() + creds = {'token': { + 'uuid': 'user-uuid', + 'token': 'auth-token', + }} + self.target = target.SoledadHTTPSyncTarget( + "http://foo/foo", + uuid4().hex, + creds, + self._soledad._crypto, + None) + def test_extra_comma(self): """ Test adapted to use encrypted content. @@ -78,29 +91,25 @@ class TestSoledadParsingSyncStream( enc_json = crypto.encrypt_docstr( doc.get_json(), doc.doc_id, doc.rev, key, secret) - tgt = target.SoledadHTTPSyncTarget( - "http://foo/foo", crypto=self._soledad._crypto) - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, "[\r\n{},\r\n]", None) - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, - '[\r\n{},\r\n{"id": "i", "rev": "r", ' - '"content": %s, "gen": 3, "trans_id": "T-sid"}' - ',\r\n]' % json.dumps(enc_json), - lambda doc, gen, trans_id: None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response("[\r\n{},\r\n]") - def test_wrong_start(self): - tgt = target.SoledadHTTPSyncTarget("http://foo/foo") + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response( + ('[\r\n{},\r\n{"id": "i", "rev": "r", ' + + '"content": %s, "gen": 3, "trans_id": "T-sid"}' + + ',\r\n]') % json.dumps(enc_json)) - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, "{}\r\n]", None) + def test_wrong_start(self): + 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{}\r\n]", None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response("\r\n{}\r\n]") - self.assertRaises(u1db.errors.BrokenSyncStream, - tgt._parse_sync_stream, "", None) + with self.assertRaises(u1db.errors.BrokenSyncStream): + self.target._parse_received_doc_response("") def test_wrong_end(self): tgt = target.SoledadHTTPSyncTarget("http://foo/foo") |