def test_add_label_columns(): table = Table( Pod, { "kind": "Table", "columnDefinitions": [], "rows": [{ "cells": [], "object": { "metadata": {} } }], }, ) add_label_columns(table, "foo, bar") assert table.columns == [ { "name": "Foo", "description": "foo label", "label": "foo" }, { "name": "Bar", "description": "bar label", "label": "bar" }, ]
def _add_label_cols(): table = Table( Pod, { "kind": "Table", "columnDefinitions": [{ "name": "A" }, { "name": "C" }, { "name": "E" }], "rows": [{ "cells": ["a", "c", "e"], "object": { "metadata": { "labels": { "foo": "bar" } } }, }] * 100, "clusters": ["c1"], }, ) add_label_columns(table, "*")
def test_add_label_columns_all(): table = Table( Pod, { "kind": "Table", "columnDefinitions": [], "rows": [{"cells": [], "object": {"metadata": {}}}], }, ) add_label_columns(table, "*") assert table.columns == [{"name": "Labels", "description": "* label", "label": "*"}]
def test_add_label_columns(): table = Table(Pod, {"kind": "Table", "columnDefinitions": [], "rows": []}) add_label_columns(table, "foo, bar") assert table.columns == [ { "name": "Foo", "description": "foo label" }, { "name": "Bar", "description": "bar label" }, ]
def test_add_label_columns_empty(): table = Table(Pod, {"kind": "Table", "columnDefinitions": [], "rows": []}) add_label_columns(table, ", ") assert table.columns == []