Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: third_party/gsutil/gslib/tests/test_setwebcfg.py

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Review fixes, updated gsutil Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/gsutil/gslib/tests/test_setwebcfg.py
diff --git a/third_party/gsutil/gslib/tests/test_setwebcfg.py b/third_party/gsutil/gslib/tests/test_setwebcfg.py
new file mode 100644
index 0000000000000000000000000000000000000000..111d3893a8ed8a00e17b0b55e08f7ca8b33d780d
--- /dev/null
+++ b/third_party/gsutil/gslib/tests/test_setwebcfg.py
@@ -0,0 +1,63 @@
+# Copyright 2013 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from xml.dom.minidom import parseString
+
+import gslib.tests.testcase as testcase
+from gslib.tests.util import ObjectToURI as suri
+
+
+WEBCFG_FULL = parseString(
+ '<WebsiteConfiguration><MainPageSuffix>main'
+ '</MainPageSuffix><NotFoundPage>404</NotFoundPage>'
+ '</WebsiteConfiguration>').toprettyxml()
+
+WEBCFG_MAIN = parseString(
+ '<WebsiteConfiguration>'
+ '<MainPageSuffix>main</MainPageSuffix>'
+ '</WebsiteConfiguration>').toprettyxml()
+
+WEBCFG_ERROR = parseString(
+ '<WebsiteConfiguration><NotFoundPage>'
+ '404</NotFoundPage></WebsiteConfiguration>').toprettyxml()
+
+WEBCFG_EMPTY = parseString('<WebsiteConfiguration/>').toprettyxml()
+
+
+class TestSetWebCfg(testcase.GsUtilIntegrationTestCase):
+ """Integration tests for setwebcfg command."""
+
+ def test_full(self):
+ bucket_uri = self.CreateBucket()
+ self.RunGsUtil(['setwebcfg', '-m', 'main', '-e', '404', suri(bucket_uri)])
+ stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
+ self.assertEquals(stdout, WEBCFG_FULL)
+
+ def test_main(self):
+ bucket_uri = self.CreateBucket()
+ self.RunGsUtil(['setwebcfg', '-m', 'main', suri(bucket_uri)])
+ stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
+ self.assertEquals(stdout, WEBCFG_MAIN)
+
+ def test_error(self):
+ bucket_uri = self.CreateBucket()
+ self.RunGsUtil(['setwebcfg', '-e', '404', suri(bucket_uri)])
+ stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
+ self.assertEquals(stdout, WEBCFG_ERROR)
+
+ def test_empty(self):
+ bucket_uri = self.CreateBucket()
+ self.RunGsUtil(['setwebcfg', suri(bucket_uri)])
+ stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
+ self.assertEquals(stdout, WEBCFG_EMPTY)

Powered by Google App Engine
This is Rietveld 408576698