test_linkpruefer: Testfall für leere Eingabe ergänzt
Linkpruefer.pruefe() hat einen dritten Zweig (leere Eingabe -> aktion "leer"), der bisher ungetestet war - die fünf bestehenden Tests deckten nur den URL- und den Datei-Zweig ab. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,19 @@ from sn_basis.functions.qgiscore_wrapper import NetworkReply
|
|||||||
class TestLinkpruefer(unittest.TestCase):
|
class TestLinkpruefer(unittest.TestCase):
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
# 1. Remote-Link erreichbar
|
# 1. Leere Eingabe
|
||||||
|
# -----------------------------------------------------
|
||||||
|
def test_leere_eingabe(self):
|
||||||
|
"""Prüft, dass eine leere Eingabe ohne Netzwerk-/Dateizugriff als 'leer' abgelehnt wird."""
|
||||||
|
lp = Linkpruefer()
|
||||||
|
result = lp.pruefe("")
|
||||||
|
|
||||||
|
self.assertFalse(result.ok)
|
||||||
|
self.assertEqual(result.aktion, "leer")
|
||||||
|
self.assertIsNone(result.kontext)
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# 2. Remote-Link erreichbar
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@patch("sn_basis.modules.linkpruefer.network_head")
|
@patch("sn_basis.modules.linkpruefer.network_head")
|
||||||
def test_remote_link_ok(self, mock_head):
|
def test_remote_link_ok(self, mock_head):
|
||||||
@@ -26,7 +38,7 @@ class TestLinkpruefer(unittest.TestCase):
|
|||||||
self.assertEqual(result.kontext, "http://example.com")
|
self.assertEqual(result.kontext, "http://example.com")
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
# 2. Remote-Link nicht erreichbar
|
# 3. Remote-Link nicht erreichbar
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@patch("sn_basis.modules.linkpruefer.network_head")
|
@patch("sn_basis.modules.linkpruefer.network_head")
|
||||||
def test_remote_link_error(self, mock_head):
|
def test_remote_link_error(self, mock_head):
|
||||||
@@ -41,7 +53,7 @@ class TestLinkpruefer(unittest.TestCase):
|
|||||||
self.assertEqual(result.kontext, "http://example.com")
|
self.assertEqual(result.kontext, "http://example.com")
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
# 3. Netzwerkfehler (None)
|
# 4. Netzwerkfehler (None)
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@patch("sn_basis.modules.linkpruefer.network_head", return_value=None)
|
@patch("sn_basis.modules.linkpruefer.network_head", return_value=None)
|
||||||
def test_remote_link_network_error(self, mock_head):
|
def test_remote_link_network_error(self, mock_head):
|
||||||
@@ -54,7 +66,7 @@ class TestLinkpruefer(unittest.TestCase):
|
|||||||
self.assertEqual(result.kontext, "http://example.com")
|
self.assertEqual(result.kontext, "http://example.com")
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
# 4. Lokaler Pfad existiert nicht
|
# 5. Lokaler Pfad existiert nicht
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@patch("sn_basis.modules.linkpruefer.file_exists", return_value=False)
|
@patch("sn_basis.modules.linkpruefer.file_exists", return_value=False)
|
||||||
def test_local_link_not_found(self, mock_exists):
|
def test_local_link_not_found(self, mock_exists):
|
||||||
@@ -67,7 +79,7 @@ class TestLinkpruefer(unittest.TestCase):
|
|||||||
self.assertEqual(result.kontext, Path("/path/to/missing/file.shp"))
|
self.assertEqual(result.kontext, Path("/path/to/missing/file.shp"))
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
# 5. Lokaler Pfad existiert
|
# 6. Lokaler Pfad existiert
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@patch("sn_basis.modules.linkpruefer.file_exists", return_value=True)
|
@patch("sn_basis.modules.linkpruefer.file_exists", return_value=True)
|
||||||
def test_local_link_ok(self, mock_exists):
|
def test_local_link_ok(self, mock_exists):
|
||||||
|
|||||||
Reference in New Issue
Block a user