Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

Commit bc481b4

Browse files
rtibblesclaude
andcommitted
test: remove over-mocked tests that don't verify real behavior
Remove TestGetSupportedSeries, TestCopyToSeries, and TestMainDispatch — these mocked every dependency and only tested that mocks were called in order, not actual behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3e3c0bf commit bc481b4

1 file changed

Lines changed: 0 additions & 159 deletions

File tree

tests/test_launchpad_copy.py

Lines changed: 0 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
from launchpad_copy import build_parser
1717
from launchpad_copy import configure_logging
1818
from launchpad_copy import get_current_series
19-
from launchpad_copy import get_supported_series
2019
from launchpad_copy import log
21-
from launchpad_copy import main
2220

2321
# --- Argparse tests ---
2422

@@ -128,7 +126,6 @@ def test_debug_flag(self):
128126
# --- Series discovery tests ---
129127

130128
has_lsb_release = shutil.which("lsb_release") is not None
131-
has_ubuntu_distro_info = shutil.which("ubuntu-distro-info") is not None
132129

133130

134131
@pytest.mark.skipif(not has_lsb_release, reason="lsb_release not available on this system")
@@ -146,34 +143,6 @@ def test_raises_on_missing_command(self):
146143
get_current_series()
147144

148145

149-
@pytest.mark.skipif(
150-
not has_ubuntu_distro_info,
151-
reason="ubuntu-distro-info not available on this system",
152-
)
153-
class TestGetSupportedSeries:
154-
"""Test dynamic series discovery using real ubuntu-distro-info."""
155-
156-
def test_returns_list_of_series(self):
157-
result = get_supported_series("jammy")
158-
assert isinstance(result, list)
159-
assert len(result) > 0
160-
161-
def test_excludes_source_series(self):
162-
result = get_supported_series("jammy")
163-
assert "jammy" not in result
164-
165-
def test_all_entries_are_non_empty_strings(self):
166-
result = get_supported_series("jammy")
167-
for s in result:
168-
assert isinstance(s, str)
169-
assert len(s) > 0
170-
171-
def test_raises_on_missing_command(self):
172-
with patch("subprocess.check_output", side_effect=FileNotFoundError("no cmd")):
173-
with pytest.raises(FileNotFoundError):
174-
get_supported_series("jammy")
175-
176-
177146
# --- LaunchpadWrapper tests ---
178147

179148

@@ -319,134 +288,6 @@ def test_vv_sets_debug_level(self):
319288
assert log.level == logging.DEBUG
320289

321290

322-
# --- main / subcommand dispatch tests ---
323-
324-
325-
class TestMainDispatch:
326-
"""Test that main dispatches to the correct subcommand."""
327-
328-
def test_dispatches_to_copy_to_series(self):
329-
330-
with (
331-
patch("launchpad_copy.cmd_copy_to_series", return_value=0) as mock_cmd,
332-
patch("sys.argv", ["launchpad_copy.py", "copy-to-series"]),
333-
):
334-
result = main()
335-
336-
mock_cmd.assert_called_once()
337-
assert result == 0
338-
339-
def test_dispatches_to_wait_for_builds(self):
340-
with (
341-
patch("launchpad_copy.cmd_wait_for_builds", return_value=0) as mock_cmd,
342-
patch(
343-
"sys.argv",
344-
[
345-
"launchpad_copy.py",
346-
"wait-for-builds",
347-
"--package",
348-
"kolibri-server",
349-
"--version",
350-
"1.0",
351-
],
352-
),
353-
):
354-
result = main()
355-
356-
mock_cmd.assert_called_once()
357-
assert result == 0
358-
359-
def test_dispatches_to_promote(self):
360-
361-
with (
362-
patch("launchpad_copy.cmd_promote", return_value=0) as mock_cmd,
363-
patch("sys.argv", ["launchpad_copy.py", "promote"]),
364-
):
365-
result = main()
366-
367-
mock_cmd.assert_called_once()
368-
assert result == 0
369-
370-
371-
# --- copy-to-series subcommand tests ---
372-
373-
374-
class TestCopyToSeries:
375-
"""Test the copy-to-series logic on LaunchpadWrapper."""
376-
377-
def test_queues_copy_for_missing_package(self):
378-
wrapper = LaunchpadWrapper()
379-
mock_ppa = MagicMock()
380-
381-
with (
382-
patch.object(
383-
type(wrapper),
384-
"proposed_ppa",
385-
new_callable=lambda: property(lambda self: mock_ppa),
386-
),
387-
patch.object(
388-
wrapper,
389-
"get_usable_sources",
390-
return_value=[("kolibri-server", "0.9.0")],
391-
),
392-
patch.object(wrapper, "get_source_for", return_value=None),
393-
patch.object(wrapper, "has_published_binaries", return_value=True),
394-
patch("launchpad_copy.get_current_series", return_value="jammy"),
395-
patch("launchpad_copy.get_supported_series", return_value=["noble"]),
396-
):
397-
wrapper.copy_to_series()
398-
399-
assert ("jammy", "noble", "Release") in wrapper.queue
400-
assert "kolibri-server" in wrapper.queue[("jammy", "noble", "Release")]
401-
402-
def test_skips_copy_when_not_built_yet(self):
403-
wrapper = LaunchpadWrapper()
404-
mock_ppa = MagicMock()
405-
406-
mock_build = MagicMock()
407-
mock_build.buildstate = "Currently building"
408-
mock_build.web_link = "https://example.com"
409-
410-
with (
411-
patch.object(
412-
type(wrapper),
413-
"proposed_ppa",
414-
new_callable=lambda: property(lambda self: mock_ppa),
415-
),
416-
patch.object(
417-
wrapper,
418-
"get_usable_sources",
419-
return_value=[("kolibri-server", "0.9.0")],
420-
),
421-
patch.object(wrapper, "get_source_for", return_value=None),
422-
patch.object(wrapper, "has_published_binaries", return_value=False),
423-
patch.object(wrapper, "get_builds_for", return_value=[mock_build]),
424-
patch("launchpad_copy.get_current_series", return_value="jammy"),
425-
patch("launchpad_copy.get_supported_series", return_value=["noble"]),
426-
):
427-
wrapper.copy_to_series()
428-
429-
assert len(wrapper.queue) == 0
430-
431-
def test_returns_zero(self):
432-
wrapper = LaunchpadWrapper()
433-
mock_ppa = MagicMock()
434-
435-
with (
436-
patch.object(
437-
type(wrapper),
438-
"proposed_ppa",
439-
new_callable=lambda: property(lambda self: mock_ppa),
440-
),
441-
patch.object(wrapper, "get_usable_sources", return_value=[]),
442-
patch("launchpad_copy.get_current_series", return_value="jammy"),
443-
patch("launchpad_copy.get_supported_series", return_value=[]),
444-
):
445-
result = wrapper.copy_to_series()
446-
447-
assert result == 0
448-
449-
450291
# --- promote subcommand tests ---
451292

452293

0 commit comments

Comments
 (0)