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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2013 Google Inc. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from xml.dom.minidom import parseString
16
17 import gslib.tests.testcase as testcase
18 from gslib.tests.util import ObjectToURI as suri
19
20
21 WEBCFG_FULL = parseString(
22 '<WebsiteConfiguration><MainPageSuffix>main'
23 '</MainPageSuffix><NotFoundPage>404</NotFoundPage>'
24 '</WebsiteConfiguration>').toprettyxml()
25
26 WEBCFG_MAIN = parseString(
27 '<WebsiteConfiguration>'
28 '<MainPageSuffix>main</MainPageSuffix>'
29 '</WebsiteConfiguration>').toprettyxml()
30
31 WEBCFG_ERROR = parseString(
32 '<WebsiteConfiguration><NotFoundPage>'
33 '404</NotFoundPage></WebsiteConfiguration>').toprettyxml()
34
35 WEBCFG_EMPTY = parseString('<WebsiteConfiguration/>').toprettyxml()
36
37
38 class TestSetWebCfg(testcase.GsUtilIntegrationTestCase):
39 """Integration tests for setwebcfg command."""
40
41 def test_full(self):
42 bucket_uri = self.CreateBucket()
43 self.RunGsUtil(['setwebcfg', '-m', 'main', '-e', '404', suri(bucket_uri)])
44 stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
45 self.assertEquals(stdout, WEBCFG_FULL)
46
47 def test_main(self):
48 bucket_uri = self.CreateBucket()
49 self.RunGsUtil(['setwebcfg', '-m', 'main', suri(bucket_uri)])
50 stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
51 self.assertEquals(stdout, WEBCFG_MAIN)
52
53 def test_error(self):
54 bucket_uri = self.CreateBucket()
55 self.RunGsUtil(['setwebcfg', '-e', '404', suri(bucket_uri)])
56 stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
57 self.assertEquals(stdout, WEBCFG_ERROR)
58
59 def test_empty(self):
60 bucket_uri = self.CreateBucket()
61 self.RunGsUtil(['setwebcfg', suri(bucket_uri)])
62 stdout = self.RunGsUtil(['getwebcfg', suri(bucket_uri)], return_stdout=True)
63 self.assertEquals(stdout, WEBCFG_EMPTY)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698