
This was removed in Iccf6228ab9e6d621d3047994b3adc192d67273c9 but should not have been as it has allowed for code format drift. This also * Pins the version of yapf to 0.24.0 * Fixes some drift * Updates formatting to the version of yapf being used Change-Id: Ie3d9fd6344a29d8ddb76a36d4a31d001a4c8b7c6
106 lines
3.1 KiB
Python
106 lines
3.1 KiB
Python
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import pytest
|
|
|
|
from promenade import kubeclient
|
|
|
|
TEST_DATA = [(
|
|
'Multi-facet update',
|
|
{
|
|
"label-a": "value1",
|
|
"label-b": "value2",
|
|
"label-c": "value3",
|
|
},
|
|
{
|
|
"label-a": "value1",
|
|
"label-c": "value4",
|
|
"label-d": "value99",
|
|
},
|
|
{
|
|
"label-b": None,
|
|
"label-c": "value4",
|
|
"label-d": "value99",
|
|
},
|
|
),
|
|
(
|
|
'Add labels when none exist',
|
|
None,
|
|
{
|
|
"label-a": "value1",
|
|
"label-b": "value2",
|
|
"label-c": "value3",
|
|
},
|
|
{
|
|
"label-a": "value1",
|
|
"label-b": "value2",
|
|
"label-c": "value3",
|
|
},
|
|
),
|
|
(
|
|
'No updates',
|
|
{
|
|
"label-a": "value1",
|
|
"label-b": "value2",
|
|
"label-c": "value3",
|
|
},
|
|
{
|
|
"label-a": "value1",
|
|
"label-b": "value2",
|
|
"label-c": "value3",
|
|
},
|
|
{},
|
|
),
|
|
(
|
|
'Delete labels',
|
|
{
|
|
"label-a": "value1",
|
|
"label-b": "value2",
|
|
"label-c": "value3",
|
|
},
|
|
{},
|
|
{
|
|
"label-a": None,
|
|
"label-b": None,
|
|
"label-c": None,
|
|
},
|
|
), (
|
|
'Delete labels when none',
|
|
None,
|
|
{},
|
|
{},
|
|
),
|
|
(
|
|
'Avoid kubernetes.io labels Deletion',
|
|
{
|
|
"label-a": "value1",
|
|
"label-b": "value2",
|
|
"kubernetes.io/hostname": "ubutubox",
|
|
},
|
|
{
|
|
"label-a": "value99",
|
|
},
|
|
{
|
|
"label-a": "value99",
|
|
"label-b": None,
|
|
},
|
|
)]
|
|
|
|
|
|
@pytest.mark.parametrize('description,existing_lbl,input_lbl,expected',
|
|
TEST_DATA)
|
|
def test_get_update_labels(description, existing_lbl, input_lbl, expected):
|
|
applied = kubeclient._get_update_labels(existing_lbl, input_lbl)
|
|
assert applied == expected
|