# Path: ensembler/tests/integrationtest_utils.py
# @contextlib.contextmanager
# def integrationtest_context(set_up_project_stage='init'):
#     temp_dir = tempfile.mkdtemp()
#     ensembler.initproject.InitProject(temp_dir)
#     cwd = os.getcwd()
# 
#     set_up_project_stage_methods = SetUpSampleProject(temp_dir)
#     set_up_method = getattr(set_up_project_stage_methods, set_up_project_stage)
#     set_up_method()
# 
#     os.chdir(temp_dir)
#     yield temp_dir
#     os.chdir(cwd)
#     shutil.rmtree(temp_dir)
# 
# Path: ensembler/utils.py
# @contextlib.contextmanager
# def enter_temp_dir():
#     """Create a temporary directory, enter, yield, exit, rmdir; used as context manager."""
#     temp_dir = tempfile.mkdtemp()
#     cwd = os.getcwd()
#     os.chdir(temp_dir)
#     yield temp_dir
#     os.chdir(cwd)
#     shutil.rmtree(temp_dir)
# 
# def get_installed_resource_filename(relative_path):
#     """
#     Returns the installation path of a resource file shipped with the code.
# 
#     Parameters
#     ----------
#     name: str
#         Name of the file to load (relative to the `ensembler` main code directory).
# 
#     Returns
#     -------
#     installed_filepath: str
#         absolute path of the installed file
# 
#     Examples
#     --------
#     >>> pathname = get_installed_resource_filename('tests/example_project/meta0.yaml')
#     """
#     installed_filepath = resource_filename(ensembler.__name__, relative_path)
# 
#     if not os.path.exists(installed_filepath):
#         raise ValueError(
#             "Sorry! {0} does not exist."
#             "If you just added it, you'll have to re-install".format(relative_path)
#         )
# 
#     return installed_filepath


import os
import shutil
import datetime
import ensembler
import ensembler.tests
import ensembler.modeling
import ensembler.cli_commands
    import modeller
    import modeller.automodel
from mock import Mock
from nose.plugins.attrib import attr
from ensembler.tests.integrationtest_utils import integrationtest_context
from ensembler.utils import enter_temp_dir, get_installed_resource_filename
            '--targets': ','.join(targets),
            '--targetsfile': False,
            '--templates': ','.join(templates),
            '--templatesfile': False,
            '--verbose': False,
        }

        ensembler.cli_commands.align.dispatch(args)
        for target in targets:
            naln_files = 0
            for dir, subdirs, files in os.walk(os.path.join(ensembler.core.default_project_dirnames.models, target)):
                for file in files:
                    if file == 'alignment.pir':
                        naln_files += 1
            assert naln_files == len(templates)

        for target in targets:
            seqid_filepath = os.path.join(ensembler.core.default_project_dirnames.models, target, 'sequence-identities.txt')
            ref_seqid_filepath = os.path.join(ref_resources_dirpath, seqid_filepath)
            with open(seqid_filepath) as seqid_file:
                seqid_file_text = seqid_file.read()
            with open(ref_seqid_filepath) as ref_seqid_file:
                ref_seqid_file_text = ref_seqid_file.read()
            print(seqid_file_text)
            print(ref_seqid_file_text)
            assert seqid_file_text == ref_seqid_file_text


@attr('slow')
def test_build_models_command():

# Path: ensembler/tests/integrationtest_utils.py
# @contextlib.contextmanager
# def integrationtest_context(set_up_project_stage='init'):
#     temp_dir = tempfile.mkdtemp()
#     ensembler.initproject.InitProject(temp_dir)
#     cwd = os.getcwd()
# 
#     set_up_project_stage_methods = SetUpSampleProject(temp_dir)
#     set_up_method = getattr(set_up_project_stage_methods, set_up_project_stage)
#     set_up_method()
# 
#     os.chdir(temp_dir)
#     yield temp_dir
#     os.chdir(cwd)
#     shutil.rmtree(temp_dir)
# 
# Path: ensembler/utils.py
# @contextlib.contextmanager
# def enter_temp_dir():
#     """Create a temporary directory, enter, yield, exit, rmdir; used as context manager."""
#     temp_dir = tempfile.mkdtemp()
#     cwd = os.getcwd()
#     os.chdir(temp_dir)
#     yield temp_dir
#     os.chdir(cwd)
#     shutil.rmtree(temp_dir)
# 
# def get_installed_resource_filename(relative_path):
#     """
#     Returns the installation path of a resource file shipped with the code.
# 
#     Parameters
#     ----------
#     name: str
#         Name of the file to load (relative to the `ensembler` main code directory).
# 
#     Returns
#     -------
#     installed_filepath: str
#         absolute path of the installed file
# 
#     Examples
#     --------
#     >>> pathname = get_installed_resource_filename('tests/example_project/meta0.yaml')
#     """
#     installed_filepath = resource_filename(ensembler.__name__, relative_path)
# 
#     if not os.path.exists(installed_filepath):
#         raise ValueError(
#             "Sorry! {0} does not exist."
#             "If you just added it, you'll have to re-install".format(relative_path)
#         )
# 
#     return installed_filepath


# Path: ensembler/tests/test_modeling.py
import os
import shutil
import datetime
import ensembler
import ensembler.tests
import ensembler.modeling
import ensembler.cli_commands
    import modeller
    import modeller.automodel
from mock import Mock
from nose.plugins.attrib import attr
from ensembler.tests.integrationtest_utils import integrationtest_context
from ensembler.utils import enter_temp_dir, get_installed_resource_filename

            '--targets': ','.join(targets),
            '--targetsfile': False,
            '--templates': ','.join(templates),
            '--templatesfile': False,
            '--verbose': False,
        }

        ensembler.cli_commands.align.dispatch(args)
        for target in targets:
            naln_files = 0
            for dir, subdirs, files in os.walk(os.path.join(ensembler.core.default_project_dirnames.models, target)):
                for file in files:
                    if file == 'alignment.pir':
                        naln_files += 1
            assert naln_files == len(templates)

        for target in targets:
            seqid_filepath = os.path.join(ensembler.core.default_project_dirnames.models, target, 'sequence-identities.txt')
            ref_seqid_filepath = os.path.join(ref_resources_dirpath, seqid_filepath)
            with open(seqid_filepath) as seqid_file:
                seqid_file_text = seqid_file.read()
            with open(ref_seqid_filepath) as ref_seqid_file:
                ref_seqid_file_text = ref_seqid_file.read()
            print(seqid_file_text)
            print(ref_seqid_file_text)
            assert seqid_file_text == ref_seqid_file_text


@attr('slow')
def test_build_models_command():

    with integrationtest_context(set_up_project_stage='aligned'):