import os

import pkg_resources
from django.core.management import call_command

TEST_LOCALE_DIR = pkg_resources.resource_filename(
    'testproject', 'locale'
)


def test_babel_compilemessages():
    call_command(
        'babel',
        'compilemessages',
        '-l', 'fi',
    )
    # Assert that the .mo file was created by attempting to delete it.
    os.unlink(
        os.path.join(TEST_LOCALE_DIR, 'fi', 'LC_MESSAGES', 'django.mo')
    )
