當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。