OLD | NEW |
(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) |
OLD | NEW |