mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-07 21:42:38 +00:00
Enable black formatting test (#259)
Enable black formatting test SUMMARY Signed-off-by: Abhijeet Kasurde akasurde@redhat.com ISSUE TYPE Bugfix Pull Request COMPONENT NAME plugins/action/k8s_info.py plugins/connection/kubectl.py plugins/doc_fragments/helm_common_options.py plugins/doc_fragments/k8s_auth_options.py plugins/doc_fragments/k8s_delete_options.py plugins/doc_fragments/k8s_name_options.py plugins/doc_fragments/k8s_resource_options.py plugins/doc_fragments/k8s_scale_options.py plugins/doc_fragments/k8s_state_options.py plugins/doc_fragments/k8s_wait_options.py plugins/filter/k8s.py plugins/inventory/k8s.py plugins/lookup/k8s.py plugins/lookup/kustomize.py plugins/module_utils/ansiblemodule.py plugins/module_utils/apply.py plugins/module_utils/args_common.py plugins/module_utils/client/discovery.py plugins/module_utils/client/resource.py plugins/module_utils/common.py plugins/module_utils/exceptions.py plugins/module_utils/hashes.py plugins/module_utils/helm.py plugins/module_utils/k8sdynamicclient.py plugins/module_utils/selector.py plugins/modules/helm.py plugins/modules/helm_info.py plugins/modules/helm_plugin.py plugins/modules/helm_plugin_info.py plugins/modules/helm_repository.py plugins/modules/helm_template.py plugins/modules/k8s.py plugins/modules/k8s_cluster_info.py plugins/modules/k8s_cp.py plugins/modules/k8s_drain.py plugins/modules/k8s_exec.py plugins/modules/k8s_info.py plugins/modules/k8s_json_patch.py plugins/modules/k8s_log.py plugins/modules/k8s_rollback.py plugins/modules/k8s_scale.py plugins/modules/k8s_service.py tests/integration/targets/kubernetes/library/test_tempfile.py tests/unit/module_utils/test_apply.py tests/unit/module_utils/test_common.py tests/unit/module_utils/test_discoverer.py tests/unit/module_utils/test_hashes.py tests/unit/module_utils/test_marshal.py tests/unit/module_utils/test_selector.py tox.ini Reviewed-by: None <None> Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: None <None>
This commit is contained in:
@@ -15,78 +15,55 @@
|
||||
# Test ConfigMap and Secret marshalling
|
||||
# tests based on https://github.com/kubernetes/kubernetes/pull/49961
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import marshal, sorted_dict
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
||||
marshal,
|
||||
sorted_dict,
|
||||
)
|
||||
|
||||
tests = [
|
||||
dict(
|
||||
resource=dict(
|
||||
kind="ConfigMap",
|
||||
name="",
|
||||
data=dict(),
|
||||
),
|
||||
expected=b'{"data":{},"kind":"ConfigMap","name":""}'
|
||||
resource=dict(kind="ConfigMap", name="", data=dict(),),
|
||||
expected=b'{"data":{},"kind":"ConfigMap","name":""}',
|
||||
),
|
||||
dict(
|
||||
resource=dict(kind="ConfigMap", name="", data=dict(one=""),),
|
||||
expected=b'{"data":{"one":""},"kind":"ConfigMap","name":""}',
|
||||
),
|
||||
dict(
|
||||
resource=dict(
|
||||
kind="ConfigMap",
|
||||
name="",
|
||||
data=dict(
|
||||
one=""
|
||||
),
|
||||
kind="ConfigMap", name="", data=dict(two="2", one="", three="3",),
|
||||
),
|
||||
expected=b'{"data":{"one":""},"kind":"ConfigMap","name":""}'
|
||||
expected=b'{"data":{"one":"","three":"3","two":"2"},"kind":"ConfigMap","name":""}',
|
||||
),
|
||||
dict(
|
||||
resource=dict(
|
||||
kind="ConfigMap",
|
||||
name="",
|
||||
data=dict(
|
||||
two="2",
|
||||
one="",
|
||||
three="3",
|
||||
),
|
||||
),
|
||||
expected=b'{"data":{"one":"","three":"3","two":"2"},"kind":"ConfigMap","name":""}'
|
||||
resource=dict(kind="Secret", type="my-type", name="", data=dict(),),
|
||||
expected=b'{"data":{},"kind":"Secret","name":"","type":"my-type"}',
|
||||
),
|
||||
dict(
|
||||
resource=dict(kind="Secret", type="my-type", name="", data=dict(one=""),),
|
||||
expected=b'{"data":{"one":""},"kind":"Secret","name":"","type":"my-type"}',
|
||||
),
|
||||
dict(
|
||||
resource=dict(
|
||||
kind="Secret",
|
||||
type="my-type",
|
||||
name="",
|
||||
data=dict(),
|
||||
data=dict(two="Mg==", one="", three="Mw==",),
|
||||
),
|
||||
expected=b'{"data":{},"kind":"Secret","name":"","type":"my-type"}'
|
||||
),
|
||||
dict(
|
||||
resource=dict(
|
||||
kind="Secret",
|
||||
type="my-type",
|
||||
name="",
|
||||
data=dict(
|
||||
one=""
|
||||
),
|
||||
),
|
||||
expected=b'{"data":{"one":""},"kind":"Secret","name":"","type":"my-type"}'
|
||||
),
|
||||
dict(
|
||||
resource=dict(
|
||||
kind="Secret",
|
||||
type="my-type",
|
||||
name="",
|
||||
data=dict(
|
||||
two="Mg==",
|
||||
one="",
|
||||
three="Mw==",
|
||||
),
|
||||
),
|
||||
expected=b'{"data":{"one":"","three":"Mw==","two":"Mg=="},"kind":"Secret","name":"","type":"my-type"}'
|
||||
expected=b'{"data":{"one":"","three":"Mw==","two":"Mg=="},"kind":"Secret","name":"","type":"my-type"}',
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_marshal():
|
||||
for test in tests:
|
||||
assert(marshal(sorted_dict(test['resource']), sorted(list(test['resource'].keys()))) == test['expected'])
|
||||
assert (
|
||||
marshal(
|
||||
sorted_dict(test["resource"]), sorted(list(test["resource"].keys()))
|
||||
)
|
||||
== test["expected"]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user