From f87ef742e8c2037fe77d031b48bd2b9e1ac0c995 Mon Sep 17 00:00:00 2001 From: rappenze Date: Wed, 16 Nov 2022 15:27:20 +0100 Subject: [PATCH] Use parameterized test for better code readability (#82194) * Use parameterized test for better code readability * Use parameterized test for better code readability * Update tests/components/fibaro/test_config_flow.py Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> --- tests/components/fibaro/test_config_flow.py | 22 ++++----------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/tests/components/fibaro/test_config_flow.py b/tests/components/fibaro/test_config_flow.py index 2a0936588cd..080cc3f4458 100644 --- a/tests/components/fibaro/test_config_flow.py +++ b/tests/components/fibaro/test_config_flow.py @@ -365,21 +365,7 @@ async def test_reauth_auth_failure(hass): assert result["errors"] == {"base": "invalid_auth"} -async def test_normalize_url_does_not_touch_valid_url(): - """Test that a correctly entered url is not touched.""" - assert _normalize_url(TEST_URL) == TEST_URL - - -async def test_normalize_url_add_missing_slash_at_the_end(): - """Test that a / is added at the end.""" - assert _normalize_url("http://192.168.1.1/api") == "http://192.168.1.1/api/" - - -async def test_normalize_url_add_api(): - """Test that api/ is added.""" - assert _normalize_url("http://192.168.1.1/") == "http://192.168.1.1/api/" - - -async def test_normalize_url_add_api_with_leading_slash(): - """Test that /api/ is added.""" - assert _normalize_url("http://192.168.1.1") == "http://192.168.1.1/api/" +@pytest.mark.parametrize("url_path", ["/api/", "/api", "/", ""]) +async def test_normalize_url(url_path: str) -> None: + """Test that the url is normalized for different entered values.""" + assert _normalize_url(f"http://192.168.1.1{url_path}") == "http://192.168.1.1/api/"