diff options
Diffstat (limited to 'unit-tests')
-rwxr-xr-x | unit-tests/unit | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/unit-tests/unit b/unit-tests/unit index 0f8a51b..b6018f9 100755 --- a/unit-tests/unit +++ b/unit-tests/unit @@ -79,7 +79,10 @@ except: sys.stdout.write(LINE) sys.stdout.write(" * Importing module...") try: + import libxml2 import dmidecode + import dmidecodeXML + passed() sys.stdout.write(" * Version: %s\n"%blue(dmidecode.version)) sys.stdout.write(" * DMI Version String: %s\n"%blue(dmidecode.dmi)) @@ -161,11 +164,79 @@ try: failed(e, 2) except LookupError, e: failed(e, 2) + + dmixml = dmidecodeXML.dmidecodeXML() + try: + sys.stdout.write(" * XML: Swapping result type dmidecodeXML::SetResultType('-')..."); + sys.stdout.flush() + test(not dmixml.SetResultType('-')) + except TypeError: + sys.stdout.write("Not working => ") + passed() + except: + sys.stdout.write("Accepted => ") + failed() + + try: + sys.stdout.write(" * XML: Swapping result type - dmidecodeXML::SetResultType(dmidecodeXML.DMIXML_DOC)..."); + sys.stdout.flush() + test(dmixml.SetResultType(dmidecodeXML.DMIXML_DOC)) + sys.stdout.write(" * XML: Swapping result type - dmidecodeXML::SetResultType(dmidecodeXML.DMIXML_NODE)..."); + sys.stdout.flush() + test(dmixml.SetResultType(dmidecodeXML.DMIXML_NODE)) + except: + failed() + + for i in bad_types: + sys.stdout.write(" * XML: Testing bad type - dmidecodeXML::QueryTypeId(%s)..." + % red(i)) + sys.stdout.flush() + try: + output_node = dmixml.QueryTypeId(i) + test(not isinstance(output_node, libxml2.xmlNode)) + except SystemError: + sys.stdout.write("Accepted => ") + failed() + except TypeError: + sys.stdout.write("Not working => ") + passed() + except ValueError: + sys.stdout.write("Not working => ") + passed() + + for i in types: + sys.stdout.write(" * XML: Testing dmidecodeXML::QueryTypeId(%s)..." + % red(i)) + sys.stdout.flush() + try: + output_node = dmixml.QueryTypeId(i) + test(isinstance(output_node, libxml2.xmlNode)) + except Exception, e: + failed(e, 2) + except: + failed() + + dmixml.SetResultType(dmidecodeXML.DMIXML_DOC) + i = 0 + for section in sections: + i += 1 + sys.stdout.write(" * XML: Testing dmidecodeXML::QuerySection('%s') (%d/%d)..." + % (cyan(section), i, len(sections))) + sys.stdout.flush() + try: + output_doc = dmixml.QuerySection(section) + test(isinstance(output_doc, libxml2.xmlDoc)) + except Exception, e: + failed(e, 2) + except: + failed() + except IOError: skipped() -except ImportError: +except ImportError, err: failed() + print err """ |