def test_write_network_with_no_usages(): """ Test given network with usages attribute set to None, the usages isn't written to output xml """ network = types.Network() buf = make_buffer() writer = XmlWriter(buf, indent=True) NetworkWriter.write_one(network, writer) writer.flush() assert_equals(decode_buffer(buf), '<network/>\n')
def test_write_network_with_empty_usages(): """ Test given network with usages attribute set empty list, the usages empty element is written to output xml """ network = types.Network(usages=[], ) buf = make_buffer() writer = XmlWriter(buf, indent=True) NetworkWriter.write_one(network, writer) writer.flush() assert_equals(decode_buffer(buf), '<network>\n' + ' <usages/>\n' + '</network>\n')
def test_write_network_with_one_usages(): """ Test given network with usages attribute set list with one value, the usages element with one value is written to output xml """ network = types.Network(usages=[types.NetworkUsage.VM], ) buf = make_buffer() writer = XmlWriter(buf, indent=True) NetworkWriter.write_one(network, writer) writer.flush() assert_equals( decode_buffer(buf), '<network>\n' + ' <usages>\n' + ' <usage>vm</usage>\n' + ' </usages>\n' + '</network>\n')
def test_write_network_with_empty_usages(): """ Test given network with usages attribute set empty list, the usages empty element is written to output xml """ network = types.Network( usages=[], ) buf = make_buffer() writer = XmlWriter(buf, indent=True) NetworkWriter.write_one(network, writer) writer.flush() assert_equals( decode_buffer(buf), '<network>\n' + ' <usages/>\n' + '</network>\n' )
def test_write_network_with_one_usages(): """ Test given network with usages attribute set list with one value, the usages element with one value is written to output xml """ network = types.Network( usages=[ types.NetworkUsage.VM ], ) buf = make_buffer() writer = XmlWriter(buf, indent=True) NetworkWriter.write_one(network, writer) writer.flush() assert_equals( decode_buffer(buf), '<network>\n' + ' <usages>\n' + ' <usage>vm</usage>\n' + ' </usages>\n' + '</network>\n' )