Ejemplo n.º 1
0
def test_check_repo_and_scheduler_no_external_schedules():
    repository = mock.MagicMock(spec=ExternalRepository)
    repository.get_external_schedules.return_value = []
    instance = mock.MagicMock(spec=DagsterInstance)
    with pytest.raises(click.UsageError,
                       match="There are no schedules defined for repository"):
        check_repo_and_scheduler(repository, instance)
Ejemplo n.º 2
0
def test_check_repo_and_scheduler_dagster_home_not_set():
    with environ({"DAGSTER_HOME": ""}):
        repository = mock.MagicMock(spec=ExternalRepository)
        repository.get_external_schedules.return_value = [mock.MagicMock()]
        instance = mock.MagicMock(spec=DagsterInstance)

        with pytest.raises(
            click.UsageError, match=re.escape("The environment variable $DAGSTER_HOME is not set.")
        ):
            check_repo_and_scheduler(repository, instance)
Ejemplo n.º 3
0
def test_check_repo_and_scheduler_instance_scheduler_not_set():
    repository = mock.MagicMock(spec=ExternalRepository)
    repository.get_external_schedules.return_value = [mock.MagicMock()]
    instance = mock.MagicMock(spec=DagsterInstance)
    type(instance).scheduler = mock.PropertyMock(return_value=None)

    with environ({"DAGSTER_HOME": "~/dagster_home"}):
        with pytest.raises(
                click.UsageError,
                match=re.escape(
                    "A scheduler must be configured to run schedule commands."
                ),
        ):
            check_repo_and_scheduler(repository, instance)