Example #1
0
 def test_lifecycle_config_storage_uri(self):
     """Test setting and getting of lifecycle config with storage_uri."""
     # create a new bucket
     bucket = self._MakeBucket()
     bucket_name = bucket.name
     uri = storage_uri('gs://' + bucket_name)
     # get lifecycle config and make sure it's empty
     xml = uri.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_EMPTY)
     # set lifecycle config
     lifecycle_config = LifecycleConfig()
     lifecycle_config.add_rule('Delete', None, LIFECYCLE_CONDITIONS)
     uri.configure_lifecycle(lifecycle_config)
     xml = uri.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_DOC)
Example #2
0
 def test_lifecycle_config_storage_uri(self):
     """Test setting and getting of lifecycle config with storage_uri."""
     # create a new bucket
     bucket = self._MakeBucket()
     bucket_name = bucket.name
     uri = storage_uri('gs://' + bucket_name)
     # get lifecycle config and make sure it's empty
     xml = uri.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_EMPTY)
     # set lifecycle config
     lifecycle_config = LifecycleConfig()
     lifecycle_config.add_rule('Delete', None, LIFECYCLE_CONDITIONS)
     uri.configure_lifecycle(lifecycle_config)
     xml = uri.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_DOC)
Example #3
0
 def test_lifecycle_config_bucket(self):
     """Test setting and getting of lifecycle config on Bucket."""
     # create a new bucket
     bucket = self._MakeBucket()
     bucket_name = bucket.name
     # now call get_bucket to see if it's really there
     bucket = self._GetConnection().get_bucket(bucket_name)
     # get lifecycle config and make sure it's empty
     xml = bucket.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_EMPTY)
     # set lifecycle config
     lifecycle_config = LifecycleConfig()
     lifecycle_config.add_rule('Delete', None, LIFECYCLE_CONDITIONS)
     bucket.configure_lifecycle(lifecycle_config)
     xml = bucket.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_DOC)
Example #4
0
 def test_lifecycle_config_bucket(self):
     """Test setting and getting of lifecycle config on Bucket."""
     # create a new bucket
     bucket = self._MakeBucket()
     bucket_name = bucket.name
     # now call get_bucket to see if it's really there
     bucket = self._GetConnection().get_bucket(bucket_name)
     # get lifecycle config and make sure it's empty
     xml = bucket.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_EMPTY)
     # set lifecycle config
     lifecycle_config = LifecycleConfig()
     lifecycle_config.add_rule('Delete', None, LIFECYCLE_CONDITIONS)
     bucket.configure_lifecycle(lifecycle_config)
     xml = bucket.get_lifecycle_config().to_xml()
     self.assertEqual(xml, LIFECYCLE_DOC)