summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Parslow <tom@almostobsolete.net>2012-09-06 20:36:47 +0100
committerThomas Parslow <tom@almostobsolete.net>2012-09-06 20:36:47 +0100
commit005509c786217daa9e8a7da3a0f256a34c206b1a (patch)
tree8650fe1b7e712f39e8a57149ddb846fe0e4bda37
parentc0d1f76ad03bee6c1e82cbb19c3d2f89b00f1809 (diff)
parent5f8d0652c846d89bbb08762aef63e96a3d045ad7 (diff)
downloadboto-005509c786217daa9e8a7da3a0f256a34c206b1a.tar.gz
Merge branch 'glacier' of github.com:boto/boto into glacier
Conflicts: boto/glacier/layer2.py
-rw-r--r--boto/glacier/layer2.py28
-rw-r--r--tests/integration/glacier/test_glacier_layer2.py64
-rw-r--r--tests/integration/glacier/test_layer2.py45
3 files changed, 70 insertions, 67 deletions
diff --git a/boto/glacier/layer2.py b/boto/glacier/layer2.py
index fbfb1843..e519ca89 100644
--- a/boto/glacier/layer2.py
+++ b/boto/glacier/layer2.py
@@ -38,13 +38,35 @@ class Layer2(object):
self.layer1 = Layer1(*args, **kwargs)
def create_vault(self, name):
- """
- Create a new vault.
+ """Creates a vault.
:type name: str
:param name: The name of the vault
+
+ :rtype: :class:`boto.glacier.vault.Vault`
+ :return: A Vault object representing the vault.
+ """
+ self.layer1.create_vault(name)
+ return self.get_vault(name)
+
+ def delete_vault(self, name):
+ """Delete a vault.
+
+ This operation deletes a vault. Amazon Glacier will delete a
+ vault only if there are no archives in the vault as per the
+ last inventory and there have been no writes to the vault
+ since the last inventory. If either of these conditions is not
+ satisfied, the vault deletion fails (that is, the vault is not
+ removed) and Amazon Glacier returns an error.
+
+ This operation is idempotent, you can send the same request
+ multiple times and it has no further effect after the first
+ time Amazon Glacier delete the specified vault.
+
+ :type vault_name: str
+ :param vault_name: The name of the vault to delete.
"""
- return self.layer1.create_vault(name)
+ return self.layer1.delete_vault(name)
def get_vault(self, name):
"""
diff --git a/tests/integration/glacier/test_glacier_layer2.py b/tests/integration/glacier/test_glacier_layer2.py
deleted file mode 100644
index a0b84ee1..00000000
--- a/tests/integration/glacier/test_glacier_layer2.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2012 Thomas Parslow http://almostobsolete.net/
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish, dis-
-# tribute, sublicense, and/or sell copies of the Software, and to permit
-# persons to whom the Software is furnished to do so, subject to the fol-
-# lowing conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
-# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-#
-
-from boto.glacier import connect_to_region
-import uuid
-import unittest
-
-class GlaicerTest (unittest.TestCase):
- glacier = True
-
- def setUp(self):
- self.conn = connect_to_region("us-east-1")
- self.vault_name = 'boto-test-vault-%s' % (uuid.uuid1(),)
- self.conn.create_vault(self.vault_name)
- self.vault = self.conn.get_vault(self.vault_name)
-
- def tearDown(self):
- self.vault.delete()
-
-
- def test_vault_name(self):
- assert self.vault.name == self.vault_name
-
- ## Once you write to a vault you can't delete it for a few hours,
- ## so this test doesn't work so well.
- # def test_upload_vault(self):
- # writer = self.vault.create_archive_writer(description="Hello world")
- # # Would be nicer to write enough to splill over into a second
- # # part, but that takes ages!
- # for i in range(12):
- # writer.write("X" * 1024)
- # writer.close()
- # archive_id = writer.get_archive_id()
-
- # job_id = self.vault.retrieve_archive(archive_id, description="my job")
-
- # # Usually at this point you;d wait for the notification via
- # # SNS (which takes about 5 hours)
-
- # job = self.vault.get_job(job_id)
- # assert job.description == "my job"
- # assert job.archive_size == 1024*12
-
- # self.vault.delete_archive(archive_id)
diff --git a/tests/integration/glacier/test_layer2.py b/tests/integration/glacier/test_layer2.py
new file mode 100644
index 00000000..caa44fa5
--- /dev/null
+++ b/tests/integration/glacier/test_layer2.py
@@ -0,0 +1,45 @@
+# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+import time
+from tests.unit import unittest
+
+from boto.glacier.layer2 import Layer1, Layer2
+
+
+class TestGlacierLayer2(unittest.TestCase):
+ glacier = True
+
+ def setUp(self):
+ self.layer2 = Layer2()
+ self.vault_name = 'testvault%s' % int(time.time())
+
+ def test_create_delete_vault(self):
+ vault = self.layer2.create_vault(self.vault_name)
+ retrieved_vault = self.layer2.get_vault(self.vault_name)
+ self.layer2.delete_vault(self.vault_name)
+ self.assertEqual(vault.name, retrieved_vault.name)
+ self.assertEqual(vault.arn, retrieved_vault.arn)
+ self.assertEqual(vault.creation_date, retrieved_vault.creation_date)
+ self.assertEqual(vault.last_inventory_date,
+ retrieved_vault.last_inventory_date)
+ self.assertEqual(vault.number_of_archives,
+ retrieved_vault.number_of_archives)