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

Unified Diff: gslib/tests/test_web.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « gslib/tests/test_versioning.py ('k') | gslib/tests/test_wildcard_iterator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gslib/tests/test_web.py
===================================================================
--- gslib/tests/test_web.py (revision 33376)
+++ gslib/tests/test_web.py (working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,80 +12,74 @@
# 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.
+"""Integration tests for the webcfg command."""
-from xml.dom.minidom import parseString
+from __future__ import absolute_import
+import json
import gslib.tests.testcase as testcase
+from gslib.tests.testcase.integration_testcase import SkipForS3
from gslib.tests.util import ObjectToURI as suri
+WEBCFG_FULL = json.loads('{"notFoundPage": "404", "mainPageSuffix": "main"}\n')
+WEBCFG_MAIN = json.loads('{"mainPageSuffix": "main"}\n')
+WEBCFG_ERROR = json.loads('{"notFoundPage": "404"}\n')
+WEBCFG_EMPTY = 'has no website configuration'
-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()
-
-
+@SkipForS3('Web set not supported for S3, web get returns XML.')
class TestWeb(testcase.GsUtilIntegrationTestCase):
- """Integration tests for the webcfg command."""
+ """Integration tests for the web command."""
- _set_cmd_prefix = ['web', 'set']
- _get_cmd_prefix = ['web', 'get']
+ _set_web_cmd = ['web', 'set']
+ _get_web_cmd = ['web', 'get']
def test_full(self):
bucket_uri = self.CreateBucket()
self.RunGsUtil(
- self._set_cmd_prefix + ['-m', 'main', '-e', '404', suri(bucket_uri)])
+ self._set_web_cmd + ['-m', 'main', '-e', '404', suri(bucket_uri)])
stdout = self.RunGsUtil(
- self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True)
- self.assertEquals(stdout, WEBCFG_FULL)
+ self._get_web_cmd + [suri(bucket_uri)], return_stdout=True)
+ self.assertEquals(json.loads(stdout), WEBCFG_FULL)
def test_main(self):
bucket_uri = self.CreateBucket()
- self.RunGsUtil(self._set_cmd_prefix + ['-m', 'main', suri(bucket_uri)])
+ self.RunGsUtil(self._set_web_cmd + ['-m', 'main', suri(bucket_uri)])
stdout = self.RunGsUtil(
- self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True)
- self.assertEquals(stdout, WEBCFG_MAIN)
+ self._get_web_cmd + [suri(bucket_uri)], return_stdout=True)
+ self.assertEquals(json.loads(stdout), WEBCFG_MAIN)
def test_error(self):
bucket_uri = self.CreateBucket()
- self.RunGsUtil(self._set_cmd_prefix + ['-e', '404', suri(bucket_uri)])
+ self.RunGsUtil(self._set_web_cmd + ['-e', '404', suri(bucket_uri)])
stdout = self.RunGsUtil(
- self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True)
- self.assertEquals(stdout, WEBCFG_ERROR)
-
+ self._get_web_cmd + [suri(bucket_uri)], return_stdout=True)
+ self.assertEquals(json.loads(stdout), WEBCFG_ERROR)
+
def test_empty(self):
bucket_uri = self.CreateBucket()
- self.RunGsUtil(self._set_cmd_prefix + [suri(bucket_uri)])
+ self.RunGsUtil(self._set_web_cmd + [suri(bucket_uri)])
stdout = self.RunGsUtil(
- self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True)
- self.assertEquals(stdout, WEBCFG_EMPTY)
+ self._get_web_cmd + [suri(bucket_uri)], return_stdout=True)
+ self.assertIn(WEBCFG_EMPTY, stdout)
def testTooFewArgumentsFails(self):
+ """Ensures web commands fail with too few arguments."""
# No arguments for get, but valid subcommand.
- stderr = self.RunGsUtil(self._get_cmd_prefix, return_stderr=True,
+ stderr = self.RunGsUtil(self._get_web_cmd, return_stderr=True,
expected_status=1)
self.assertIn('command requires at least', stderr)
# No arguments for set, but valid subcommand.
- stderr = self.RunGsUtil(self._set_cmd_prefix, return_stderr=True,
+ stderr = self.RunGsUtil(self._set_web_cmd, return_stderr=True,
expected_status=1)
self.assertIn('command requires at least', stderr)
# Neither arguments nor subcommand.
stderr = self.RunGsUtil(['web'], return_stderr=True, expected_status=1)
self.assertIn('command requires at least', stderr)
-
+
+
class TestWebOldAlias(TestWeb):
- _set_cmd_prefix = ['setwebcfg']
- _get_cmd_prefix = ['getwebcfg']
+ _set_web_cmd = ['setwebcfg']
+ _get_web_cmd = ['getwebcfg']
« no previous file with comments | « gslib/tests/test_versioning.py ('k') | gslib/tests/test_wildcard_iterator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698