本文整理汇总了Python中ovirtsdk4.reader.Reader类的典型用法代码示例。如果您正苦于以下问题:Python Reader类的具体用法?Python Reader怎么用?Python Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_date_with_invalid_value
def test_read_date_with_invalid_value():
"""
Test given invalid value raises error.
"""
io_buffer = make_buffer('<value>ugly</value>')
xml_reader = XmlReader(io_buffer)
Reader.read_date(xml_reader)
示例2: test_read_with_xml_reader
def test_read_with_xml_reader():
"""
Test if read method accepts xml reader.
"""
cursor = XmlReader(make_buffer('<vm/>'))
Reader.read(cursor)
cursor.close()
示例3: test_read_boolean_invalid_value
def test_read_boolean_invalid_value():
"""
Test given 'ugly' raises error.
"""
io_buffer = make_buffer('<value>ugly</value>')
xml_reader = XmlReader(io_buffer)
Reader.read_boolean(xml_reader)
示例4: test_read_leaves_position
def test_read_leaves_position():
"""
Test if read method leaves it positioned in the next element.
"""
cursor = XmlReader(make_buffer('<root><vm/><next/></root>'))
cursor.read()
Reader.read(cursor)
assert_equals(cursor.node_name(), 'next')
cursor.close()
示例5: test_read_given_two_different_objects
def test_read_given_two_different_objects():
"""
Test if given two different consecutive objects, they can be read with two calls.
"""
cursor = XmlReader(make_buffer('<root><vm/><disk/></root>'))
cursor.read()
vm = Reader.read(cursor)
disk = Reader.read(cursor)
assert_true(isinstance(vm, types.Vm))
assert_true(isinstance(disk, types.Disk))
示例6: test_read_unknonw_tag
def test_read_unknonw_tag():
"""
Test that when an unknonw tag is received an exception with a
message is generated.
"""
cursor = XmlReader(make_buffer('<html>blah<html>'))
cursor.read()
with assert_raises(Error) as context:
Reader.read(cursor)
assert_equals(str(context.exception), "Can't find a reader for tag 'html'")
示例7: test_read_dates_empty_list_without_close_tag
def test_read_dates_empty_list_without_close_tag():
"""
Test given no values without close tag returns empty list.
"""
io_buffer = make_buffer('<list/>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_dates(xml_reader), [])
示例8: test_read_decimals_with_one_value
def test_read_decimals_with_one_value():
"""
Test given one value returns list containing one value.
"""
io_buffer = make_buffer('<list><value>1.1</value></list>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_decimals(xml_reader), [1.1])
示例9: test_read_decimal_with_valid_value
def test_read_decimal_with_valid_value():
"""
Test given valid value returns that value.
"""
io_buffer = make_buffer('<value>1.1</value>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_decimal(xml_reader), 1.1)
示例10: test_read_integers_with_two_values
def test_read_integers_with_two_values():
"""
Test given two values returns list containing two values.
"""
io_buffer = make_buffer('<list><value>0</value><value>1</value></list>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_integers(xml_reader), [0, 1])
示例11: test_read_integers_empty_list_with_close_tag
def test_read_integers_empty_list_with_close_tag():
"""
Test given no values with close tag returns empty list.
"""
io_buffer = make_buffer('<list></list>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_integers(xml_reader), [])
示例12: test_read_integer_with_valid_value
def test_read_integer_with_valid_value():
"""
Test given valid value returns that value.
"""
io_buffer = make_buffer('<value>0</value>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_integer(xml_reader), 0)
示例13: test_read_booleans_with_one_value
def test_read_booleans_with_one_value():
"""
Test given one value returns list containing one value.
"""
io_buffer = make_buffer('<list><value>false</value></list>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_booleans(xml_reader), [False])
示例14: test_read_boolean_0
def test_read_boolean_0():
"""
Test given '0' return False.
"""
io_buffer = make_buffer('<value>0</value>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_boolean(xml_reader), False)
示例15: test_read_boolean_1
def test_read_boolean_1():
"""
Test given '1' return True.
"""
io_buffer = make_buffer('<value>1</value>')
xml_reader = XmlReader(io_buffer)
assert_equals(Reader.read_boolean(xml_reader), True)