
Library `requests` can handle files, pipes, dictionaries and iterators as `data` argument. Use 'json' argument to send json requests. Rewrite some unittests using mock. Change-Id: I95b71eb2716dc57708ed105659ffece376bd8344
31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
# Copyright 2012 OpenStack Foundation
|
|
# All Rights Reserved.
|
|
#
|
|
# 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 testtools
|
|
|
|
from glareclient.common import utils
|
|
|
|
|
|
class TestUtils(testtools.TestCase):
|
|
|
|
def test_make_size_human_readable(self):
|
|
self.assertEqual("106B", utils.make_size_human_readable(106))
|
|
self.assertEqual("1000kB", utils.make_size_human_readable(1024000))
|
|
self.assertEqual("1MB", utils.make_size_human_readable(1048576))
|
|
self.assertEqual("1.4GB", utils.make_size_human_readable(1476395008))
|
|
self.assertEqual("9.3MB", utils.make_size_human_readable(9761280))
|
|
self.assertEqual("0B", utils.make_size_human_readable(None))
|