class TestXMLparser:
    """Test the XMLparser class."""
    def test_real_xml_file(self, real_xml_file, validate=True):
        parser = XMLparser(real_xml_file, validate=validate)
        assert isinstance(parser, amespahdbpythonsuite.xmlparser.XMLparser)
        assert parser.verify_schema() is True
        parser.to_pahdb_dict()

    def test_real_xml_file2(self, real_xml_file, validate=False):
        parser = XMLparser(real_xml_file, validate=validate)
        assert isinstance(parser, amespahdbpythonsuite.xmlparser.XMLparser)
        parser.to_pahdb_dict()

    def test_real_xml_file_experimental(self, real_xml_file_experimental):
        parser = XMLparser(real_xml_file_experimental)
        assert isinstance(parser, amespahdbpythonsuite.xmlparser.XMLparser)
        assert parser.verify_schema() is True
        parser.to_pahdb_dict()

    def test_illformed_xml_file(self, illformed_xml_file, validate=True):
        with pytest.raises(XMLSyntaxError):
            parser = XMLparser(illformed_xml_file, validate=validate)
            parser.verify_schema()

    def test_illformed_xml_file2(self, illformed_xml_file, validate=False):
        with pytest.raises(XMLSyntaxError):
            parser = XMLparser(illformed_xml_file, validate=validate)
            parser.to_pahdb_dict()

    def test_not_an_xml_file(self, tmpdir_factory, not_an_xml_file):
        with pytest.raises(TypeError):
            parser = XMLparser(not_an_xml_file)
            parser.verify_schema()
            parser.to_pahdb_dict()

    with pytest.raises(OSError):
        parser = XMLparser(filename='fake.txt')
        parser.verify_schema()
 def test_not_an_xml_file(self, tmpdir_factory, not_an_xml_file):
     with pytest.raises(TypeError):
         parser = XMLparser(not_an_xml_file)
         parser.verify_schema()
         parser.to_pahdb_dict()
 def test_illformed_xml_file2(self, illformed_xml_file, validate=False):
     with pytest.raises(XMLSyntaxError):
         parser = XMLparser(illformed_xml_file, validate=validate)
         parser.to_pahdb_dict()
 def test_illformed_xml_file(self, illformed_xml_file, validate=True):
     with pytest.raises(XMLSyntaxError):
         parser = XMLparser(illformed_xml_file, validate=validate)
         parser.verify_schema()
 def test_real_xml_file_experimental(self, real_xml_file_experimental):
     parser = XMLparser(real_xml_file_experimental)
     assert isinstance(parser, amespahdbpythonsuite.xmlparser.XMLparser)
     assert parser.verify_schema() is True
     parser.to_pahdb_dict()
 def test_real_xml_file2(self, real_xml_file, validate=False):
     parser = XMLparser(real_xml_file, validate=validate)
     assert isinstance(parser, amespahdbpythonsuite.xmlparser.XMLparser)
     parser.to_pahdb_dict()
 def test_real_xml_file(self, real_xml_file, validate=True):
     parser = XMLparser(real_xml_file, validate=validate)
     assert isinstance(parser, amespahdbpythonsuite.xmlparser.XMLparser)
     assert parser.verify_schema() is True
     parser.to_pahdb_dict()
Exemple #8
0
"""

import pkg_resources

from amespahdbpythonsuite.xmlparser import XMLparser

import matplotlib.pyplot as plt

if __name__ == '__main__':

    path = 'resources/pahdb-theoretical_cutdown.xml'

    xml = pkg_resources.resource_filename('amespahdbpythonsuite', path)

    parser = XMLparser(xml)

    parser.verify_schema()

    library = parser.to_pahdb_dict()

    plt.bar([d['frequency'] for d in library['species'][18]['transitions']],
            [d['intensity'] for d in library['species'][18]['transitions']],
            20, color='red', edgecolor="none")

    plt.title('stick absorption spectrum of coronene (UID=18)')

    plt.xlabel('frequency [cm$^{-1}$]')

    plt.ylabel('integrated cross-section [km mol$^{-1}$]')