Exemple #1
0
def test_stage_factory_raises_errors_for_invalid_stage_directories(
        project_repo_location: Path):
    with raises(FileExistsError, match=r'does not exist'):
        path_to_stage_dir = project_repo_location / 'not_a_stage'
        stage_factory(path_to_stage_dir)
    with raises(BodyworkStageConfigError, match=r'STAGE_TYPE in \[default\]'):
        path_to_stage_dir = project_repo_location / 'stage_6_bad_stage_type'
        stage_factory(path_to_stage_dir)
Exemple #2
0
def test_stage_factory_yields_stage_data_for_valid_stage(
        project_repo_location: Path):
    path_to_stage_dir = project_repo_location / 'stage_1_good'
    try:
        stage_factory(path_to_stage_dir)
        assert True
    except Exception:
        assert False
Exemple #3
0
def test_stage_equality_operations(project_repo_location: Path):
    path_to_stage_1_dir = project_repo_location / 'stage_1_good'
    stage_1 = stage_factory(path_to_stage_1_dir)

    path_to_stage_5_dir = project_repo_location / 'stage_5_good'
    stage_5 = stage_factory(path_to_stage_5_dir)

    assert stage_1 == stage_1
    assert stage_1 != stage_5
Exemple #4
0
def test_stage_secret_parsing(project_repo_location: Path):
    path_to_stage_1_dir = project_repo_location / 'stage_1_good'
    stage_1 = stage_factory(path_to_stage_1_dir)

    path_to_stage_4_dir = project_repo_location / 'stage_4_good'
    stage_4 = stage_factory(path_to_stage_4_dir)

    assert stage_1.env_vars_from_secrets[0] == ('foobar-secret', 'FOO')
    assert stage_1.env_vars_from_secrets[1] == ('foobar-secret', 'BAR')
    assert stage_4.env_vars_from_secrets == []
Exemple #5
0
def test_stage_factory_yields_correct_data_for_batch_stages(
        project_repo_location: Path):
    path_to_stage_dir = project_repo_location / 'stage_1_good'
    stage_info = stage_factory(path_to_stage_dir)
    assert stage_info.path_to_stage_dir == path_to_stage_dir
    assert type(stage_info.config) == BodyworkConfig
    assert stage_info.executable_script_path == path_to_stage_dir / 'main.py'
    assert stage_info.name == 'stage_1_good'
    assert type(stage_info) == BatchStage
    assert stage_info.retries == 4
    assert stage_info.max_completion_time == 60
Exemple #6
0
def test_stage_factory_yields_correct_data_for_service_stages(
        project_repo_location: Path):
    path_to_stage_dir = project_repo_location / 'stage_5_good'
    stage_info = stage_factory(path_to_stage_dir)
    assert stage_info.path_to_stage_dir == path_to_stage_dir
    assert type(stage_info.config) == BodyworkConfig
    assert stage_info.executable_script_path == path_to_stage_dir / 'main.py'
    assert stage_info.name == 'stage_5_good'
    assert type(stage_info) == ServiceStage
    assert stage_info.replicas == 2
    assert stage_info.max_startup_time == 60
    assert stage_info.port == 5000