#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import os.path
import unittest

import snowprofile

_here = os.path.dirname(os.path.realpath(__file__))


class TestIOCAAML5XML(unittest.TestCase):

    def test_read_caaml5_xml_default_example(self):
        """
        Test a caaml.org CAAML 5 XML example file
        """
        sp = snowprofile.io.read_caaml5_xml(os.path.join(_here, 'resources', 'Snowprofile_IACS_SLF7245.xml'))

        assert sp.observer.source_id == "SLF"
        assert sp.weather.cloudiness == 'BKN'
        assert len(sp.stability_tests) == 2

    def test_read_caaml5_xml_niviz_example(self):
        """
        Test a random CAAML 5 XML file written by NiViz
        """
        sp = snowprofile.io.read_caaml5_xml(os.path.join(_here, 'resources', 'Profilev5-1.caaml'))

        assert sp.location.name == 'Col de Porte'
        assert sp.weather.cloudiness == 'CLR'
        assert sp.profile_depth == 1.27
        assert len(sp.temperature_profiles) == 1
        assert len(sp.density_profiles) == 1


if __name__ == "__main__":
    unittest.main()
