def test_read_with_xml_reader(): """ Test if read method accepts xml reader. """ cursor = XmlReader(make_buffer('<vm/>')) Reader.read(cursor) cursor.close()
def test_read_with_xml_reader(): """ Test if read method accepts xml reader. """ cursor = XmlReader(make_buffer('<vm/>')) Reader.read(cursor) cursor.close()
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()
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()
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'")
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))
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))
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'")
def test_read_given_two_different_objects(): """ Test if given given an empty document, read returns None. """ cursor = XmlReader(make_buffer('<root/>')) cursor.read() object = Reader.read(cursor) assert_is_none(object)
def test_read_given_two_different_objects(): """ Test if given given an empty document, read returns None. """ cursor = XmlReader(make_buffer('<root/>')) cursor.read() object = Reader.read(cursor) assert_is_none(object)
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))
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))
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))
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))
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")
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")
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))
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))
def test_read_with_io(): """ Test if read method accepts io object. """ Reader.read(make_buffer('<vm/>'))
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))
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))
def test_read_given_incorrect_reader(): """ Test if given incorrect input data, read method raises an exception. """ Reader.read(make_buffer('<ugly/>'))
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))
def test_read_given_incorrect_type(): """ Test if read give incorrect type, it raises exception. """ Reader.read(0)
def test_read_with_io(): """ Test if read method accepts io object. """ Reader.read(make_buffer('<vm/>'))
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))
def test_read_given_incorrect_reader(): """ Test if given incorrect input data, read method raises an exception. """ Reader.read(make_buffer('<ugly/>'))
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))
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))
def test_read_given_incorrect_type(): """ Test if read give incorrect type, it raises exception. """ Reader.read(0)