当前位置: 首页>>代码示例>>Python>>正文


Python reader.Reader类代码示例

本文整理汇总了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)
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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()
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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)
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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()
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:9,代码来源:test_reader.py

示例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))
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:10,代码来源:test_reader.py

示例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'")
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:10,代码来源:test_reader.py

示例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), [])
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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])
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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)
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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])
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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), [])
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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)
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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])
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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)
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py

示例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)
开发者ID:machacekondra,项目名称:ovirt-engine-sdk,代码行数:7,代码来源:test_reader.py


注:本文中的ovirtsdk4.reader.Reader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。