You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2016/01/18 16:18:54 UTC
[10/14] libcloud git commit: Add tests for extension methods.
Add tests for extension methods.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/484d9746
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/484d9746
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/484d9746
Branch: refs/heads/trunk
Commit: 484d9746701778ff643ec8cc8a40d1937f673927
Parents: 4be89d2
Author: Tomaz Muraus <to...@apache.org>
Authored: Mon Jan 18 11:35:45 2016 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Mon Jan 18 11:35:45 2016 +0100
----------------------------------------------------------------------
.../fixtures/backblaze_b2/b2_hide_file.json | 7 ++
.../backblaze_b2/b2_list_file_versions.json | 69 ++++++++++++++++++++
libcloud/test/storage/test_backblaze_b2.py | 41 ++++++++++++
3 files changed, 117 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/484d9746/libcloud/test/storage/fixtures/backblaze_b2/b2_hide_file.json
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/fixtures/backblaze_b2/b2_hide_file.json b/libcloud/test/storage/fixtures/backblaze_b2/b2_hide_file.json
new file mode 100644
index 0000000..c339410
--- /dev/null
+++ b/libcloud/test/storage/fixtures/backblaze_b2/b2_hide_file.json
@@ -0,0 +1,7 @@
+{
+ "action": "hide",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f1089c2d0af334258_d20160118_m103421_c001_v0001015_t0019",
+ "fileName": "2.txt",
+ "size": 0,
+ "uploadTimestamp": 1453113261000
+}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/484d9746/libcloud/test/storage/fixtures/backblaze_b2/b2_list_file_versions.json
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/fixtures/backblaze_b2/b2_list_file_versions.json b/libcloud/test/storage/fixtures/backblaze_b2/b2_list_file_versions.json
new file mode 100644
index 0000000..a5d8118
--- /dev/null
+++ b/libcloud/test/storage/fixtures/backblaze_b2/b2_list_file_versions.json
@@ -0,0 +1,69 @@
+{
+ "files": [
+ {
+ "action": "hide",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f11356114bd70b633_d20151219_m171034_c001_v0001015_t0017",
+ "fileName": "1.txt",
+ "size": 0,
+ "uploadTimestamp": 1450545034000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f114de3a6d4984677_d20151219_m165328_c001_v0001011_t0013",
+ "fileName": "1.txt",
+ "size": 4,
+ "uploadTimestamp": 1450544008000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f112d803c648864bd_d20151219_m172606_c001_v0001013_t0006",
+ "fileName": "2.txt",
+ "size": 2,
+ "uploadTimestamp": 1450545966000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f112d1d656ee3d11a_d20160117_m215631_c001_v0001017_t0020",
+ "fileName": "test10.txt",
+ "size": 24,
+ "uploadTimestamp": 1453067791000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f108012807a71d788_d20160110_m155541_c001_v0001001_t0016",
+ "fileName": "test5.txt",
+ "size": 24,
+ "uploadTimestamp": 1452441341000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f118ba13b3b4343ae_d20151220_m135857_c001_v0001003_t0007",
+ "fileName": "test5.txt",
+ "size": 24,
+ "uploadTimestamp": 1450619937000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f1071961a62d3426d_d20160110_m155708_c001_v0001013_t0042",
+ "fileName": "test6.txt",
+ "size": 24,
+ "uploadTimestamp": 1452441428000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f106af7e634b95e05_d20160117_m180806_c001_v0001017_t0017",
+ "fileName": "test8.txt",
+ "size": 24,
+ "uploadTimestamp": 1453054086000
+ },
+ {
+ "action": "upload",
+ "fileId": "4_z481c37de2e1ab3bf5e150710_f114bdc6fc4c203d9_d20160117_m215616_c001_v0001017_t0006",
+ "fileName": "test9.txt",
+ "size": 24,
+ "uploadTimestamp": 1453067776000
+ }
+ ],
+ "nextFileId": null,
+ "nextFileName": null
+}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/484d9746/libcloud/test/storage/test_backblaze_b2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_backblaze_b2.py b/libcloud/test/storage/test_backblaze_b2.py
index 871f52b..6a62746 100644
--- a/libcloud/test/storage/test_backblaze_b2.py
+++ b/libcloud/test/storage/test_backblaze_b2.py
@@ -103,6 +103,33 @@ class BackblazeB2StorageDriverTestCase(unittest.TestCase):
result = self.driver.delete_object(obj=obj)
self.assertTrue(result)
+ def test_ex_hide_object(self):
+ container = self.driver.list_containers()[0]
+ container_id = container.extra['id']
+ obj = self.driver.ex_hide_object(container_id=container_id,
+ object_name='2.txt')
+ self.assertEqual(obj.name, '2.txt')
+
+ def test_ex_list_object_versions(self):
+ container = self.driver.list_containers()[0]
+ container_id = container.extra['id']
+ objects = self.driver.ex_list_object_versions(container_id=container_id)
+ self.assertEqual(len(objects), 9)
+
+ def test_ex_get_upload_data(self):
+ container = self.driver.list_containers()[0]
+ container_id = container.extra['id']
+ data = self.driver.ex_get_upload_data(container_id=container_id)
+ self.assertEqual(data['authorizationToken'], 'nope')
+ self.assertEqual(data['bucketId'], '481c37de2e1ab3bf5e150710')
+ self.assertEqual(data['uploadUrl'], 'https://podxxx.backblaze.com/b2api/v1/b2_upload_file/abcd/defg')
+
+ def test_ex_get_upload_url(self):
+ container = self.driver.list_containers()[0]
+ container_id = container.extra['id']
+ url = self.driver.ex_get_upload_url(container_id=container_id)
+ self.assertEqual(url, 'https://podxxx.backblaze.com/b2api/v1/b2_upload_file/abcd/defg')
+
class BackblazeB2MockHttp(StorageMockHttp, MockHttpTestCase):
fixtures = StorageFileFixtures('backblaze_b2')
@@ -158,6 +185,20 @@ class BackblazeB2MockHttp(StorageMockHttp, MockHttpTestCase):
raise AssertionError('Unsupported method')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+ def _b2api_v1_b2_list_file_versions(self, method, url, body, headers):
+ if method == 'GET':
+ body = self.fixtures.load('b2_list_file_versions.json')
+ else:
+ raise AssertionError('Unsupported method')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ def _b2api_v1_b2_hide_file(self, method, url, body, headers):
+ if method == 'POST':
+ body = self.fixtures.load('b2_hide_file.json')
+ else:
+ raise AssertionError('Unsupported method')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
class BackblazeB2MockRawResponse(MockRawResponse):
def _file_test00001_2_txt(self, method, url, body, headers):