Пример #1
0
def test_job_factory_create_invalid_cloud():
    service_config = Mock()
    job_config = {'cloud': 'fake'}

    job_factory = BaseJobFactory(
        service_name='test',
        job_types={'gce': GCETestJob}
    )

    with raises(MashJobException):
        job_factory.create_job(job_config, service_config)
Пример #2
0
def test_job_factory_create_invalid_config(mock_job_init):
    service_config = Mock()
    job_config = {'cloud': 'gce'}

    mock_job_init.side_effect = Exception('Invalid parameters')

    job_factory = BaseJobFactory(
        service_name='test',
        job_types={'gce': GCETestJob}
    )

    with raises(MashJobException):
        job_factory.create_job(job_config, service_config)
Пример #3
0
def test_job_factory_create(mock_job_init):
    service_config = Mock()
    job_config = {'cloud': 'gce'}

    mock_job_init.return_value = None

    job_factory = BaseJobFactory(
        service_name='test',
        job_types={'gce': GCETestJob}
    )

    value = job_factory.create_job(job_config, service_config)
    assert isinstance(value, GCETestJob)
Пример #4
0
def test_job_factory_skip(mock_job_init):
    service_config = Mock()
    job_config = {'cloud': None}

    mock_job_init.return_value = None

    job_factory = BaseJobFactory(
        service_name='test',
        job_types={'gce': GCETestJob},
        can_skip=True
    )

    job = job_factory.create_job(job_config, service_config)
    assert isinstance(job, NoOpJob)