diff --git a/bin/st b/bin/st index 51a7637881..1a4bf34312 100755 --- a/bin/st +++ b/bin/st @@ -1132,6 +1132,11 @@ def st_stat(options, args): if not args: try: headers = conn.head_account() + if options.verbose > 1: + options.print_queue.put(''' +StorageURL: %s +Auth Token: %s +'''.strip('\n') % (conn.url, conn.token)) container_count = int(headers.get('x-account-container-count', 0)) object_count = int(headers.get('x-account-object-count', 0)) bytes_used = int(headers.get('x-account-bytes-used', 0)) @@ -1397,8 +1402,10 @@ Example: '''.strip('\n') % globals()) parser.add_option('-s', '--snet', action='store_true', dest='snet', default=False, help='Use SERVICENET internal network') - parser.add_option('-q', '--quiet', action='store_false', dest='verbose', - default=True, help='Suppress status output') + parser.add_option('-v', '--verbose', action='count', dest='verbose', + default=1, help='Print more info') + parser.add_option('-q', '--quiet', action='store_const', dest='verbose', + const=0, default=1, help='Suppress status output') parser.add_option('-a', '--all', action='store_true', dest='yes_all', default=False, help='Indicate that you really want the ' 'whole account for commands that require --all in such ' diff --git a/test/unit/account/test_replicator.py b/test/unit/account/test_replicator.py new file mode 100644 index 0000000000..6b3d045eaa --- /dev/null +++ b/test/unit/account/test_replicator.py @@ -0,0 +1,32 @@ +# Copyright (c) 2010 OpenStack, LLC. +# +# 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. + +import unittest +from swift.account import replicator + + +class TestReplicator(unittest.TestCase): + """ + swift.account.replicator is currently just a subclass with some class + variables overridden, but at least this test stub will ensure proper Python + syntax. + """ + + def test_placeholder(self): + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/test/unit/common/middleware/test_auth.py b/test/unit/common/middleware/test_auth.py index a7ec9199a2..800ecb4cb7 100644 --- a/test/unit/common/middleware/test_auth.py +++ b/test/unit/common/middleware/test_auth.py @@ -67,25 +67,33 @@ def mock_http_connect(response, headers=None, with_exc=False): self.headers = headers if self.headers is None: self.headers = {} + def getresponse(self): if self.with_exc: raise Exception('test') return self + def getheader(self, header): return self.headers[header] + def read(self, amt=None): return '' + def close(self): return + return lambda *args, **kwargs: FakeConn(response, headers, with_exc) class Logger(object): + def __init__(self): self.error_value = None self.exception_value = None + def error(self, msg, *args, **kwargs): self.error_value = (msg, args, kwargs) + def exception(self, msg, *args, **kwargs): _, exc, _ = sys.exc_info() self.exception_value = (msg, @@ -99,7 +107,7 @@ class FakeApp(object): def __call__(self, env, start_response): self.i_was_called = True - req = Request(env) + req = Request.blank('', environ=env) if 'swift.authorize' in env: resp = env['swift.authorize'](req) if resp: @@ -110,6 +118,7 @@ class FakeApp(object): def start_response(*args): pass + class TestAuth(unittest.TestCase): def setUp(self): @@ -418,6 +427,5 @@ class TestAuth(unittest.TestCase): self.assert_(resp.startswith('403'), resp) - if __name__ == '__main__': unittest.main() diff --git a/test/unit/common/test_bench.py b/test/unit/common/test_bench.py new file mode 100644 index 0000000000..7b75aba79e --- /dev/null +++ b/test/unit/common/test_bench.py @@ -0,0 +1,29 @@ +# Copyright (c) 2010 OpenStack, LLC. +# +# 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. + +# TODO: Tests + +import unittest +from swift.common import bench + + +class TestBench(unittest.TestCase): + + def test_placeholder(self): + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/test/unit/common/test_daemon.py b/test/unit/common/test_daemon.py new file mode 100644 index 0000000000..e2db43caa6 --- /dev/null +++ b/test/unit/common/test_daemon.py @@ -0,0 +1,29 @@ +# Copyright (c) 2010 OpenStack, LLC. +# +# 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. + +# TODO: Tests + +import unittest +from swift.common import daemon + + +class TestDaemon(unittest.TestCase): + + def test_placeholder(self): + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/test/unit/common/test_direct_client.py b/test/unit/common/test_direct_client.py index a925c118bb..35ed07ffd7 100644 --- a/test/unit/common/test_direct_client.py +++ b/test/unit/common/test_direct_client.py @@ -17,7 +17,10 @@ import unittest -class TestAuditor(unittest.TestCase): +from swift.common import direct_client + + +class TestDirectClient(unittest.TestCase): def test_placeholder(self): pass diff --git a/test/unit/common/test_exceptions.py b/test/unit/common/test_exceptions.py index bfb251b139..35a5801e77 100644 --- a/test/unit/common/test_exceptions.py +++ b/test/unit/common/test_exceptions.py @@ -18,7 +18,8 @@ import unittest from swift.common import exceptions -class TestAuditor(unittest.TestCase): + +class TestExceptions(unittest.TestCase): def test_placeholder(self): pass diff --git a/test/unit/container/test_replicator.py b/test/unit/container/test_replicator.py new file mode 100644 index 0000000000..8f7a032893 --- /dev/null +++ b/test/unit/container/test_replicator.py @@ -0,0 +1,32 @@ +# Copyright (c) 2010 OpenStack, LLC. +# +# 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. + +import unittest +from swift.container import replicator + + +class TestReplicator(unittest.TestCase): + """ + swift.container.replicator is currently just a subclass with some class + variables overridden, but at least this test stub will ensure proper Python + syntax. + """ + + def test_placeholder(self): + pass + + +if __name__ == '__main__': + unittest.main()