Ejemplo n.º 1
0
    def test_build_egg_if_in_development(self, active_config):
        from dallinger.deployment import assemble_experiment_temp_dir

        tmp_egg = tempfile.mkdtemp()
        (Path(tmp_egg) / "funniest").mkdir()
        (Path(tmp_egg) / "funniest" / "__init__.py").write_text("")
        (Path(tmp_egg) / "README").write_text("Foobar")
        (Path(tmp_egg) / "setup.py").write_text(
            textwrap.dedent(
                """\
        from setuptools import setup

        setup(name='funniest',
            version='0.1',
            description='The funniest joke in the world',
            url='http://github.com/storborg/funniest',
            author='Flying Circus',
            author_email='*****@*****.**',
            license='MIT',
            packages=['funniest'],
            zip_safe=False)
        """
            )
        )
        with mock.patch(
            "dallinger.deployment.get_editable_dallinger_path"
        ) as get_editable_dallinger_path:
            get_editable_dallinger_path.return_value = tmp_egg
            log = mock.Mock()
            tmp_dir = assemble_experiment_temp_dir(log, active_config, for_remote=True)

        assert "Dallinger is installed as an editable package" in log.call_args[0][0]
        assert "dallinger==" not in (Path(tmp_dir) / "requirements.txt").read_text()
        shutil.rmtree(tmp_dir)
Ejemplo n.º 2
0
def experiment_dir_merged(experiment_dir, active_config):
    """A temp directory with files from the standard test experiment, merged
    with standard Dallinger files by the same process that occurs in production.
    """
    from dallinger.deployment import assemble_experiment_temp_dir

    current_dir = os.getcwd()
    destination = assemble_experiment_temp_dir(active_config)
    os.chdir(destination)
    yield
    os.chdir(current_dir)
Ejemplo n.º 3
0
    def test_dont_build_egg_if_not_in_development(self, active_config):
        from dallinger.deployment import assemble_experiment_temp_dir

        with mock.patch(
            "dallinger.deployment.get_editable_dallinger_path"
        ) as get_editable_dallinger_path:
            # When dallinger is not installed as editable egg the requirements
            # file sent to heroku will include a version pin
            get_editable_dallinger_path.return_value = None
            log = mock.Mock()
            tmp_dir = assemble_experiment_temp_dir(log, active_config)

        assert "dallinger==" in (Path(tmp_dir) / "requirements.txt").read_text()
Ejemplo n.º 4
0
def experiment_dir_merged(experiment_dir, active_config):
    """A temp directory with files from the standard test experiment, merged
    with standard Dallinger files by the same process that occurs in production.
    """
    from dallinger.deployment import assemble_experiment_temp_dir
    from dallinger.deployment import ensure_constraints_file_presence

    current_dir = os.getcwd()
    ensure_constraints_file_presence(current_dir)
    with mock.patch(
        "dallinger.deployment.get_editable_dallinger_path"
    ) as get_editable_dallinger_path:
        # When dallinger is not installed as editable egg the requirements
        # file sent to heroku will include a version pin
        get_editable_dallinger_path.return_value = None
        log = mock.Mock()
        destination = assemble_experiment_temp_dir(log, active_config)
        os.chdir(destination)
        yield
    os.chdir(current_dir)