"""test profile module."""
try:  # py3
    from unittest import mock
except ImportError:  # py2
    import mock

import pytest


def test_import():
    """test normal import.

    the error happened because
    module run the profile populator in testing mode.
    in profile_populator it need IO where it disable on testing.
    """
    with pytest.raises(IOError):
        from melissa import profile  # NOQA


def test_import_with_mock_profile_populator():
    """test importing but mock some obj.

    the error happened because
    module run load_profile after run mocked profile_populator func.
    because it is not exist IOError is raised.
    """
    with mock.patch(
            'melissa.profile_populator.profile_populator') \
            as mock_profile_populator:
        with pytest.raises(IOError):
            from melissa import profile  # NOQA
        mock_profile_populator.assert_called_once_with()

add test for profile module.