mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-26 21:33:02 +00:00
* Cleanup gha * test by removing matrix excludes * Rename sanity tests * trigger integration tests * Fix ansible-lint workflow * Fix concurrency * Add ansible-lint config * Add ansible-lint config * Fix integration and lint issues * integration wf * fix yamllint issues * fix yamllint issues * update readme and add ignore-2.16.txt * fix ansible-doc * Add version * Use /dev/random to generate random data The GHA environment has difficultly generating entropy. Trying to read from /dev/urandom just blocks forever. We don't care if the random data is cryptographically secure; it's just garbage data for the test. Read from /dev/random, instead. This is only used during the k8s_copy test target. This also removes the custom test module that was being used to generate the files. It's not worth maintaining this for two task that can be replaced with some simple command/shell tasks. * Fix saniry errors * test github_action fix * Address review comments * Remove default types * review comments * isort fixes * remove tags * Add setuptools to venv * Test gh changes * update changelog * update ignore-2.16 * Fix indentation in inventory plugin example * Update .github/workflows/integration-tests.yaml * Update integration-tests.yaml --------- Co-authored-by: Mike Graves <mgraves@redhat.com> Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
106 lines
2.6 KiB
Python
106 lines
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright: (c) 2022, Ansible Project
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
from datetime import datetime
|
|
|
|
from ansible_collections.kubernetes.core.plugins.action.k8s_info import RemoveOmit
|
|
|
|
|
|
def get_omit_token():
|
|
return "__omit_place_holder__%s" % datetime.now().strftime("%Y%m%d%H%M%S")
|
|
|
|
|
|
def test_remove_omit_from_str():
|
|
omit_token = get_omit_token()
|
|
src = """
|
|
project: ansible
|
|
collection: {omit}
|
|
""".format(
|
|
omit=omit_token
|
|
)
|
|
result = RemoveOmit(src, omit_value=omit_token).output()
|
|
assert len(result) == 1
|
|
assert result[0] == dict(project="ansible")
|
|
|
|
|
|
def test_remove_omit_from_list():
|
|
omit_token = get_omit_token()
|
|
src = """
|
|
items:
|
|
- {omit}
|
|
""".format(
|
|
omit=omit_token
|
|
)
|
|
result = RemoveOmit(src, omit_value=omit_token).output()
|
|
assert len(result) == 1
|
|
assert result[0] == dict(items=[])
|
|
|
|
|
|
def test_remove_omit_from_list_of_dict():
|
|
omit_token = get_omit_token()
|
|
src = """
|
|
items:
|
|
- owner: ansible
|
|
team: {omit}
|
|
- simple_list_item
|
|
""".format(
|
|
omit=omit_token
|
|
)
|
|
result = RemoveOmit(src, omit_value=omit_token).output()
|
|
assert len(result) == 1
|
|
assert result[0] == dict(items=[dict(owner="ansible"), "simple_list_item"])
|
|
|
|
|
|
def test_remove_omit_combined():
|
|
omit_token = get_omit_token()
|
|
src = """
|
|
items:
|
|
- {omit}
|
|
- list_item_a
|
|
- list_item_b
|
|
parent:
|
|
child:
|
|
subchilda: {omit}
|
|
subchildb:
|
|
name: {omit}
|
|
age: 3
|
|
""".format(
|
|
omit=omit_token
|
|
)
|
|
result = RemoveOmit(src, omit_value=omit_token).output()
|
|
assert len(result) == 1
|
|
assert result[0] == dict(
|
|
items=["list_item_a", "list_item_b"],
|
|
parent=dict(child=dict(subchildb=dict(age=3))),
|
|
)
|
|
|
|
|
|
def test_remove_omit_mutiple_documents():
|
|
omit_token = get_omit_token()
|
|
src = [
|
|
"""
|
|
project: ansible
|
|
collection: {omit}
|
|
""".format(
|
|
omit=omit_token
|
|
),
|
|
"---",
|
|
"""
|
|
project: kubernetes
|
|
environment: production
|
|
collection: {omit}""".format(
|
|
omit=omit_token
|
|
),
|
|
]
|
|
src = "\n".join(src)
|
|
print(src)
|
|
result = RemoveOmit(src, omit_value=omit_token).output()
|
|
assert len(result) == 2
|
|
assert result[0] == dict(project="ansible")
|
|
assert result[1] == dict(project="kubernetes", environment="production")
|