import unittest
from pathlib import Path
from packaging.version import Version

import pymagglobal

# Implicitly check the package index __all__
# Not a test-case since `import *` is only allowed at module level
from pymagglobal import *


class ParserTestPackage(unittest.TestCase):
    '''Unit-tests for the package i.e. __init__.py'''

    def test_version(self):
        '''Check if pymagglobal.__version__ conforms PEP 440'''
        version = Version(pymagglobal.__version__)

    def test_models(self):
        '''Check if built-in model-files exist'''
        for model_fn in pymagglobal.models.values():
            with self.subTest(msg=model_fn):
                self.assertTrue(Path(model_fn).is_file())