def test_append_additional_labels_to_tasks__overwriting_label(log_mock):
    """Should not ovewrite existing previously label."""
    task1 = task('/t1', labels={'source_key': '__val__'})
    append_additional_labels_to_tasks(
        {
            'source_key':
            TaskLabelRegexGenerator('__(.*)__', '\\1', 'non_existing_key')
        }, [task1])
    assert task1.labels['source_key'] == '__val__'
    log_mock.debug.assert_called_once()
def test_append_additional_labels_to_tasks__generate_returns_None(log_mock):
    """Generate method for generator returns None."""
    class TestTaskLabelGenerator(TaskLabelGenerator):
        def generate(self, task):
            return None

    task1 = task('/t1', labels={'source_key': 'source_val'})
    append_additional_labels_to_tasks({'target_key': TestTaskLabelGenerator()},
                                      [task1])
    log_mock.debug.assert_called_once()