def extraspec_sel(obj, do_raise=False):
# Have to extract the key and value for later use...
- key, value = obj.items()[0]
+ key, value = list(obj.items())[0]
return dict(key=key, value=value)
root = xmlutil.TemplateElement(tagname, selector=extraspec_sel)
def index(self, req):
"""Returns the list of volume types."""
context = req.environ['cinder.context']
- vol_types = volume_types.get_all_types(context).values()
+ vol_types = volume_types.get_all_types(context)
+ vol_types = list(vol_types.values())
req.cache_resource(vol_types, name='types')
return self._view_builder.index(req, vol_types)
tmpInsertPos = parent.find(tagnameList[i])
if tmpInsertPos is None:
break
- elif not cmp(parent.attrib, tmpattrib) == 0:
+ elif parent.attrib != tmpattrib:
break
parent = tmpInsertPos
insertIndex = i + 1
def setUp(self):
"""Run before each test."""
super(LimiterTest, self).setUp()
- self.tiny = range(1)
- self.small = range(10)
- self.medium = range(1000)
- self.large = range(10000)
+ self.tiny = list(range(1))
+ self.small = list(range(10))
+ self.medium = list(range(1000))
+ self.large = list(range(10000))
def test_limiter_offset_zero(self):
"""Test offset key works with 0."""
def test_limiter_limit_and_offset(self):
"""Test request with both limit and offset."""
- items = range(2000)
+ items = list(range(2000))
req = webob.Request.blank('/?offset=1&limit=3')
self.assertEqual(items[1:4], common.limited(items, req))
req = webob.Request.blank('/?offset=3&limit=0')
def test_limiter_custom_max_limit(self):
"""Test a max_limit other than 1000."""
- items = range(2000)
+ items = list(range(2000))
req = webob.Request.blank('/?offset=1&limit=3')
self.assertEqual(
items[1:4], common.limited(items, req, max_limit=2000))
def test_id_with_xml_format(self):
result = self._bounce_id('foo.xml')
- self.assertEqual('foo', result)
+ self.assertEqual(b'foo', result)
def test_id_with_json_format(self):
result = self._bounce_id('foo.json')
- self.assertEqual('foo', result)
+ self.assertEqual(b'foo', result)
def test_id_with_bad_format(self):
result = self._bounce_id('foo.bad')
- self.assertEqual('foo.bad', result)
+ self.assertEqual(b'foo.bad', result)
selector='scope0:scope1:scope2:key3')
key3.text = xmlutil.Selector()
serializer = xmlutil.MasterTemplate(root, 1)
- xml_list = []
- xml_list.append("<?xmlversion='1.0'encoding='UTF-8'?><test>")
- xml_list.append("<scope0><key1>Value1</key1><scope1>")
- xml_list.append("<key2>Value2</key2><scope2><key3>Value3</key3>")
- xml_list.append("</scope2></scope1></scope0></test>")
- expected_xml = ''.join(xml_list)
+ expected_xml = (b"<?xmlversion='1.0'encoding='UTF-8'?><test>"
+ b"<scope0><key1>Value1</key1><scope1>"
+ b"<key2>Value2</key2><scope2><key3>Value3</key3>"
+ b"</scope2></scope1></scope0></test>")
result = serializer.serialize(obj)
- result = result.replace('\n', '').replace(' ', '')
+ result = result.replace(b'\n', b'').replace(b' ', b'')
self.assertEqual(expected_xml, result)
class MiscellaneousXMLUtilTests(test.TestCase):
def test_make_flat_dict(self):
- expected_xml = ("<?xml version='1.0' encoding='UTF-8'?>\n"
- '<wrapper><a>foo</a><b>bar</b></wrapper>')
+ expected_xml = (b"<?xml version='1.0' encoding='UTF-8'?>\n"
+ b'<wrapper><a>foo</a></wrapper>')
root = xmlutil.make_flat_dict('wrapper')
tmpl = xmlutil.MasterTemplate(root, 1)
- result = tmpl.serialize(dict(wrapper=dict(a='foo', b='bar')))
+ result = tmpl.serialize(dict(wrapper=dict(a='foo')))
self.assertEqual(expected_xml, result)
cinder.tests.unit.api.openstack.test_wsgi
+cinder.tests.unit.api.test_common
+cinder.tests.unit.api.test_extensions
+cinder.tests.unit.api.test_versions
+cinder.tests.unit.api.test_xmlutil
cinder.tests.unit.image.test_cache
cinder.tests.unit.image.test_glance
cinder.tests.unit.keymgr.test_mock_key_mgr