Sync requirements with openstack-common/requirements
Allow prettytable 0.7.x specifically. Add testcase. Remove setuptools_git from test-requires, already part of setup_require Change-Id: If0d114cc6ec0f84ea75d798adb5ebc424605b22e
This commit is contained in:
		
							
								
								
									
										52
									
								
								tests/test_utils.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								tests/test_utils.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
# Copyright 2013 OpenStack LLC.
 | 
			
		||||
# 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 cStringIO
 | 
			
		||||
import sys
 | 
			
		||||
import unittest2
 | 
			
		||||
 | 
			
		||||
from ceilometerclient.common import utils
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UtilsTest(unittest2.TestCase):
 | 
			
		||||
 | 
			
		||||
    def test_prettytable(self):
 | 
			
		||||
        class Struct:
 | 
			
		||||
            def __init__(self, **entries):
 | 
			
		||||
                self.__dict__.update(entries)
 | 
			
		||||
 | 
			
		||||
        # test that the prettytable output is wellformatted (left-aligned)
 | 
			
		||||
        columns = ['ID', 'Name']
 | 
			
		||||
        val = ['Name1', 'another', 'veeeery long']
 | 
			
		||||
        images = [Struct(**{'id': i ** 16, 'name': val[i]})
 | 
			
		||||
                  for i in range(len(val))]
 | 
			
		||||
 | 
			
		||||
        saved_stdout = sys.stdout
 | 
			
		||||
        try:
 | 
			
		||||
            sys.stdout = output_dict = cStringIO.StringIO()
 | 
			
		||||
            utils.print_dict({'K': 'k', 'Key': 'Value'})
 | 
			
		||||
 | 
			
		||||
        finally:
 | 
			
		||||
            sys.stdout = saved_stdout
 | 
			
		||||
 | 
			
		||||
        self.assertEqual(output_dict.getvalue(), '''\
 | 
			
		||||
+----------+-------+
 | 
			
		||||
| Property | Value |
 | 
			
		||||
+----------+-------+
 | 
			
		||||
| K        | k     |
 | 
			
		||||
| Key      | Value |
 | 
			
		||||
+----------+-------+
 | 
			
		||||
''')
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
# This file is managed by openstack-depends
 | 
			
		||||
argparse
 | 
			
		||||
prettytable>=0.6,<0.7
 | 
			
		||||
python-keystoneclient>=0.1.2
 | 
			
		||||
httplib2
 | 
			
		||||
iso8601>=0.1.4
 | 
			
		||||
prettytable>=0.6,<0.8
 | 
			
		||||
python-keystoneclient>=0.2,<0.3
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
# This file is managed by openstack-depends
 | 
			
		||||
distribute>=0.6.24
 | 
			
		||||
mox
 | 
			
		||||
mox>=0.5.3
 | 
			
		||||
nose
 | 
			
		||||
nose-exclude
 | 
			
		||||
nosehtmloutput>=0.0.3
 | 
			
		||||
nosexcover
 | 
			
		||||
openstack.nose_plugin
 | 
			
		||||
nosehtmloutput
 | 
			
		||||
openstack.nose_plugin>=0.7
 | 
			
		||||
pep8==1.3.3
 | 
			
		||||
setuptools-git>=0.4
 | 
			
		||||
sphinx>=1.1.2
 | 
			
		||||
unittest2
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user