當前位置: 首頁>>代碼示例>>Python>>正文


Python Reader.read方法代碼示例

本文整理匯總了Python中ovirtsdk4.reader.Reader.read方法的典型用法代碼示例。如果您正苦於以下問題:Python Reader.read方法的具體用法?Python Reader.read怎麽用?Python Reader.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ovirtsdk4.reader.Reader的用法示例。


在下文中一共展示了Reader.read方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_read_with_xml_reader

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
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,代碼行數:9,代碼來源:test_reader.py

示例2: test_read_leaves_position

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
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,代碼行數:11,代碼來源:test_reader.py

示例3: test_read_unknonw_tag

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
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,代碼行數:12,代碼來源:test_reader.py

示例4: test_read_given_two_different_objects

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
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,代碼行數:12,代碼來源:test_reader.py

示例5: test_read_given_two_disks

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_two_disks():
    """
    Test if given two disks, it creates list of Disks.
    """
    disks = Reader.read(make_buffer('<disks><disk/><disk/></disks>'))
    assert_true(isinstance(disks, list))
    assert_equals(len(disks), 2)
    assert_true(isinstance(disks[0], types.Disk))
    assert_true(isinstance(disks[1], types.Disk))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:11,代碼來源:test_reader.py

示例6: test_read_given_two_vms

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_two_vms():
    """
    Test if given two vms, it creates list of VMs.
    """
    vms = Reader.read(make_buffer('<vms><vm/><vm/></vms>'))
    assert_true(isinstance(vms, list))
    assert_equals(len(vms), 2)
    assert_true(isinstance(vms[0], types.Vm))
    assert_true(isinstance(vms[1], types.Vm))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:11,代碼來源:test_reader.py

示例7: test_read_given_openstack_image_provider

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_openstack_image_provider():
    """
    Test if given Openstack image provider, it creates Openstack
    image provider object.
    """
    openstack_image_provider = Reader.read(
        make_buffer(
            '<openstack_image_provider>' +
                '<name>myprovider</name>' +
            '</openstack_image_provider>'
        )
    )
    assert_true(
        isinstance(openstack_image_provider, types.OpenStackImageProvider)
    )
    assert_equals(openstack_image_provider.name, "myprovider")
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:18,代碼來源:test_reader.py

示例8: test_read_given_two_openstack_image_providers

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_two_openstack_image_providers():
    """
    Test if given two Openstack image provider, it creates list
    of Openstack image providers object.
    """
    openstack_image_providers = Reader.read(
        make_buffer(
            '<openstack_image_providers>' +
                '<openstack_image_provider/>' +
                '<openstack_image_provider/>' +
            '</openstack_image_providers>'
        )
    )
    assert_true(isinstance(openstack_image_providers, list))
    assert_equals(len(openstack_image_providers), 2)
    assert_true(isinstance(openstack_image_providers[0], types.OpenStackImageProvider))
    assert_true(isinstance(openstack_image_providers[1], types.OpenStackImageProvider))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:19,代碼來源:test_reader.py

示例9: test_read_supports_strings

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_supports_strings():
    """
    Test that the generic `read` methods supports strings as parameters.
    """
    vm = Reader.read('<vm/>')
    assert_true(isinstance(vm, types.Vm))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:8,代碼來源:test_reader.py

示例10: test_read_given_disk

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_disk():
    """
    Test if given disk, it creates disk object.
    """
    disk = Reader.read(make_buffer('<disk/>'))
    assert_true(isinstance(disk, types.Disk))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:8,代碼來源:test_reader.py

示例11: test_read_given_vm

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_vm():
    """
    Test if given vm, it creates VM object.
    """
    object = Reader.read(make_buffer('<vm/>'))
    assert_true(isinstance(object, types.Vm))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:8,代碼來源:test_reader.py

示例12: test_read_given_incorrect_reader

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_incorrect_reader():
    """
    Test if given incorrect input data, read method raises an exception.
    """
    Reader.read(make_buffer('<ugly/>'))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:7,代碼來源:test_reader.py

示例13: test_read_given_incorrect_type

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_given_incorrect_type():
    """
    Test if read give incorrect type, it raises exception.
    """
    Reader.read(0)
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:7,代碼來源:test_reader.py

示例14: test_read_with_io

# 需要導入模塊: from ovirtsdk4.reader import Reader [as 別名]
# 或者: from ovirtsdk4.reader.Reader import read [as 別名]
def test_read_with_io():
    """
    Test if read method accepts io object.
    """
    Reader.read(make_buffer('<vm/>'))
開發者ID:machacekondra,項目名稱:ovirt-engine-sdk,代碼行數:7,代碼來源:test_reader.py


注:本文中的ovirtsdk4.reader.Reader.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。