Skip to content

Commit

Permalink
simplify assert in test_disable_tcp_keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
dstandish committed May 27, 2022
1 parent 576cd02 commit 0ae2852
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions tests/providers/cncf/kubernetes/hooks/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,17 @@ def test_disable_verify_ssl(
assert isinstance(api_conn, kubernetes.client.api_client.ApiClient)

@pytest.mark.parametrize(
'disable_tcp_keepalive, conn_id, should_disable',
'disable_tcp_keepalive, conn_id, expected',
(
(True, None, True),
(None, None, False),
(False, None, False),
(None, 'disable_tcp_keepalive', True),
(True, 'disable_tcp_keepalive', True),
(False, 'disable_tcp_keepalive', False),
(None, 'disable_tcp_keepalive_empty', False),
(True, 'disable_tcp_keepalive_empty', True),
(False, 'disable_tcp_keepalive_empty', False),
(True, None, False),
(None, None, True),
(False, None, True),
(None, 'disable_tcp_keepalive', False),
(True, 'disable_tcp_keepalive', False),
(False, 'disable_tcp_keepalive', True),
(None, 'disable_tcp_keepalive_empty', True),
(True, 'disable_tcp_keepalive_empty', False),
(False, 'disable_tcp_keepalive_empty', True),
),
)
@patch("kubernetes.config.incluster_config.InClusterConfigLoader", new=MagicMock())
Expand All @@ -189,18 +189,15 @@ def test_disable_tcp_keepalive(
mock_enable,
disable_tcp_keepalive,
conn_id,
should_disable,
expected,
):
"""
Verifies whether enable tcp keepalive is called depending on combination of hook
param and connection extra. Hook param should beat extra.
"""
kubernetes_hook = KubernetesHook(conn_id=conn_id, disable_tcp_keepalive=disable_tcp_keepalive)
api_conn = kubernetes_hook.get_conn()
if not should_disable:
assert mock_enable.called
else:
assert not mock_enable.called
assert mock_enable.called is expected
assert isinstance(api_conn, kubernetes.client.api_client.ApiClient)

@pytest.mark.parametrize(
Expand Down

0 comments on commit 0ae2852

Please sign in to comment.