Example #1
0
def test_stop_chronos_job():
    service = "my_service"
    instance = "my_instance"
    cluster = "my_cluster"
    existing_jobs = [
        {
            "name": "job_v1",
            "disabled": False
        },
        {
            "name": "job_v2",
            "disabled": False
        },
        {
            "name": "job_v3",
            "disabled": True
        },
    ]
    with mock.patch(
            "paasta_tools.chronos_serviceinit.chronos_tools.chronos.ChronosClient",
            autospec=True,
    ) as mock_client, mock.patch("paasta_tools.chronos_serviceinit._log",
                                 autospec=True):
        chronos_serviceinit.stop_chronos_job(service, instance, mock_client,
                                             cluster, existing_jobs)
        assert mock_client.update.call_count == 3
        assert mock_client.delete_tasks.call_count == 3
        for job in existing_jobs:
            assert job["disabled"] is True
            mock_client.update.assert_any_call(job)
            mock_client.delete_tasks.assert_any_call(job["name"])
Example #2
0
def test_stop_chronos_job():
    service = 'my_service'
    instance = 'my_instance'
    cluster = 'my_cluster'
    existing_jobs = [
        {
            'name': 'job_v1',
            'disabled': False
        },
        {
            'name': 'job_v2',
            'disabled': False
        },
        {
            'name': 'job_v3',
            'disabled': True
        },
    ]
    with mock.patch(
            'paasta_tools.chronos_serviceinit.chronos_tools.chronos.ChronosClient',
            autospec=True,
    ) as mock_client, mock.patch(
            'paasta_tools.chronos_serviceinit._log',
            autospec=True,
    ):
        chronos_serviceinit.stop_chronos_job(service, instance, mock_client,
                                             cluster, existing_jobs)
        assert mock_client.update.call_count == 3
        assert mock_client.delete_tasks.call_count == 3
        for job in existing_jobs:
            assert job['disabled'] is True
            mock_client.update.assert_any_call(job)
            mock_client.delete_tasks.assert_any_call(job['name'])
def test_stop_chronos_job():
    service = 'my_service'
    instance = 'my_instance'
    cluster = 'my_cluster'
    existing_jobs = [{'name': 'job_v1', 'disabled': False},
                     {'name': 'job_v2', 'disabled': False},
                     {'name': 'job_v3', 'disabled': True}]
    with contextlib.nested(
        mock.patch('paasta_tools.chronos_serviceinit.chronos_tools.chronos.ChronosClient', autospec=True),
    ) as (
        mock_client,
    ):
        chronos_serviceinit.stop_chronos_job(service, instance, mock_client, cluster, existing_jobs)
        assert mock_client.update.call_count == 3
        assert mock_client.delete_tasks.call_count == 3
        for job in existing_jobs:
            assert job['disabled'] is True
            mock_client.update.assert_any_call(job)
            mock_client.delete_tasks.assert_any_call(job['name'])
def test_stop_chronos_job():
    service = "my_service"
    instance = "my_instance"
    cluster = "my_cluster"
    existing_jobs = [
        {"name": "job_v1", "disabled": False},
        {"name": "job_v2", "disabled": False},
        {"name": "job_v3", "disabled": True},
    ]
    with contextlib.nested(
        mock.patch("paasta_tools.chronos_serviceinit.chronos_tools.chronos.ChronosClient", autospec=True)
    ) as (mock_client,):
        chronos_serviceinit.stop_chronos_job(service, instance, mock_client, cluster, existing_jobs)
        assert mock_client.update.call_count == 3
        assert mock_client.delete_tasks.call_count == 3
        for job in existing_jobs:
            assert job["disabled"] is True
            mock_client.update.assert_any_call(job)
            mock_client.delete_tasks.assert_any_call(job["name"])