Add per-repo cover image support for RSS feed items
Add image_url column to repos table with migration, CLI image add/remove commands, and Media RSS <media:content> elements in generated feed output. New CLI commands: ghrel image add <repo> <url>, ghrel image remove <repo>
This commit is contained in:
@@ -130,6 +130,89 @@ class TestCliDaemon:
|
||||
cmd_check_for_daemon(db_path) # Should not raise
|
||||
|
||||
|
||||
class TestCliImage:
|
||||
def _setup_db(self, tmp_path):
|
||||
db_path = str(tmp_path / "test.db")
|
||||
conn = sqlite3.connect(db_path)
|
||||
_create_tables(conn)
|
||||
add_repo(conn, "owner/repo")
|
||||
conn.close()
|
||||
return db_path
|
||||
|
||||
def test_image_add(self, tmp_path):
|
||||
db_path = self._setup_db(tmp_path)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "--db-path", db_path,
|
||||
"image", "add", "owner/repo", "https://example.com/logo.png"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "Set image" in result.stdout
|
||||
|
||||
def test_image_add_invalid_url(self, tmp_path):
|
||||
db_path = self._setup_db(tmp_path)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "--db-path", db_path,
|
||||
"image", "add", "owner/repo", "not-a-url"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
assert result.returncode != 0
|
||||
assert "http:// or https://" in result.stderr
|
||||
|
||||
def test_image_add_invalid_repo(self, tmp_path):
|
||||
db_path = self._setup_db(tmp_path)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "--db-path", db_path,
|
||||
"image", "add", "invalid", "https://example.com/logo.png"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
assert result.returncode != 0
|
||||
assert "Invalid repo format" in result.stderr
|
||||
|
||||
def test_image_add_nonexistent_repo(self, tmp_path):
|
||||
db_path = self._setup_db(tmp_path)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "--db-path", db_path,
|
||||
"image", "add", "other/repo", "https://example.com/logo.png"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
assert result.returncode != 0
|
||||
assert "not found" in result.stderr
|
||||
|
||||
def test_image_remove(self, tmp_path):
|
||||
db_path = self._setup_db(tmp_path)
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "--db-path", db_path,
|
||||
"image", "add", "owner/repo", "https://example.com/logo.png"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "--db-path", db_path,
|
||||
"image", "remove", "owner/repo"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "Removed image" in result.stdout
|
||||
|
||||
def test_image_remove_no_image(self, tmp_path):
|
||||
db_path = self._setup_db(tmp_path)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "--db-path", db_path,
|
||||
"image", "remove", "owner/repo"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
assert result.returncode != 0
|
||||
assert "No image set" in result.stderr
|
||||
|
||||
def test_image_help(self):
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "src.cli", "image", "--help"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "cover image" in result.stdout.lower()
|
||||
|
||||
|
||||
class TestCliAddRemove:
|
||||
def test_add_invalid_format(self, tmp_path):
|
||||
db_path = str(tmp_path / "test.db")
|
||||
|
||||
Reference in New Issue
Block a user