Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / telemetry / third_party / gsutilz / gslib / tests / test_logging.py
blob375c52c4f9165ca8d06887e2204f0f5abfe92b7f
1 # -*- coding: utf-8 -*-
2 # Copyright 2013 Google Inc. All Rights Reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 """Integration tests for logging command."""
17 from __future__ import absolute_import
19 import gslib.tests.testcase as testcase
20 from gslib.tests.testcase.integration_testcase import SkipForS3
21 from gslib.tests.util import ObjectToURI as suri
24 @SkipForS3('Logging command requires S3 ACL configuration on target bucket.')
25 class TestLogging(testcase.GsUtilIntegrationTestCase):
26 """Integration tests for logging command."""
28 _enable_log_cmd = ['logging', 'set', 'on']
29 _disable_log_cmd = ['logging', 'set', 'off']
30 _get_log_cmd = ['logging', 'get']
32 def testLogging(self):
33 """Tests enabling and disabling logging."""
34 bucket_uri = self.CreateBucket()
35 bucket_suri = suri(bucket_uri)
36 stderr = self.RunGsUtil(
37 self._enable_log_cmd + ['-b', bucket_suri, bucket_suri],
38 return_stderr=True)
39 self.assertIn('Enabling logging', stderr)
41 stdout = self.RunGsUtil(self._get_log_cmd + [bucket_suri],
42 return_stdout=True)
43 self.assertIn('LogObjectPrefix'.lower(), stdout.lower())
45 stderr = self.RunGsUtil(self._disable_log_cmd + [bucket_suri],
46 return_stderr=True)
47 self.assertIn('Disabling logging', stderr)
49 def testTooFewArgumentsFails(self):
50 """Ensures logging commands fail with too few arguments."""
51 # No arguments for enable, but valid subcommand.
52 stderr = self.RunGsUtil(self._enable_log_cmd, return_stderr=True,
53 expected_status=1)
54 self.assertIn('command requires at least', stderr)
56 # No arguments for disable, but valid subcommand.
57 stderr = self.RunGsUtil(self._disable_log_cmd, return_stderr=True,
58 expected_status=1)
59 self.assertIn('command requires at least', stderr)
61 # No arguments for get, but valid subcommand.
62 stderr = self.RunGsUtil(self._get_log_cmd, return_stderr=True,
63 expected_status=1)
64 self.assertIn('command requires at least', stderr)
66 # Neither arguments nor subcommand.
67 stderr = self.RunGsUtil(['logging'], return_stderr=True, expected_status=1)
68 self.assertIn('command requires at least', stderr)
71 class TestLoggingOldAlias(TestLogging):
72 _enable_log_cmd = ['enablelogging']
73 _disable_log_cmd = ['disablelogging']
74 _get_log_cmd = ['getlogging']