Add spool inventory and print archive backup to GitHub backup (#870)

GitHub backup can now optionally include spool inventory (with usage
  history) and print archive metadata as JSON. Both toggles are off by
  default. No binary files (gcode/3MF) are included.
This commit is contained in:
maziggy
2026-04-02 09:59:00 +02:00
parent ad96337587
commit f4df4393be
19 changed files with 393 additions and 67 deletions
@@ -28,6 +28,8 @@ class TestGitHubBackupConfigAPI:
"backup_kprofiles": True,
"backup_cloud_profiles": True,
"backup_settings": False,
"backup_spools": False,
"backup_archives": False,
"enabled": True,
}
response = await async_client.post("/api/v1/github-backup/config", json=data)
@@ -37,6 +39,8 @@ class TestGitHubBackupConfigAPI:
assert result["branch"] == "main"
assert result["has_token"] is True
assert result["enabled"] is True
assert result["backup_spools"] is False
assert result["backup_archives"] is False
# Token should not be exposed in response
assert "access_token" not in result
@@ -67,6 +71,30 @@ class TestGitHubBackupConfigAPI:
assert result["branch"] == "develop"
assert result["schedule_type"] == "weekly"
@pytest.mark.asyncio
@pytest.mark.integration
async def test_create_config_with_spools_and_archives(self, async_client: AsyncClient):
"""Verify config with spool and archive backup enabled."""
data = {
"repository_url": "https://github.com/test/spoolarchive",
"access_token": "ghp_spooltoken",
"branch": "main",
"schedule_enabled": False,
"schedule_type": "daily",
"backup_kprofiles": True,
"backup_cloud_profiles": False,
"backup_settings": False,
"backup_spools": True,
"backup_archives": True,
"enabled": True,
}
response = await async_client.post("/api/v1/github-backup/config", json=data)
assert response.status_code == 200
result = response.json()
assert result["backup_spools"] is True
assert result["backup_archives"] is True
assert result["backup_cloud_profiles"] is False
@pytest.mark.asyncio
@pytest.mark.integration
async def test_update_config_partial(self, async_client: AsyncClient):
@@ -81,6 +109,8 @@ class TestGitHubBackupConfigAPI:
"backup_kprofiles": True,
"backup_cloud_profiles": True,
"backup_settings": False,
"backup_spools": False,
"backup_archives": False,
"enabled": True,
}
await async_client.post("/api/v1/github-backup/config", json=create_data)
@@ -98,6 +128,40 @@ class TestGitHubBackupConfigAPI:
# Original values should be preserved
assert result["repository_url"] == "https://github.com/test/update"
@pytest.mark.asyncio
@pytest.mark.integration
async def test_update_config_enable_spools_and_archives(self, async_client: AsyncClient):
"""Verify partial update can enable spool and archive backup."""
# Create config first
create_data = {
"repository_url": "https://github.com/test/updatetoggle",
"access_token": "ghp_toggletoken",
"branch": "main",
"schedule_enabled": False,
"schedule_type": "daily",
"backup_kprofiles": True,
"backup_cloud_profiles": True,
"backup_settings": False,
"backup_spools": False,
"backup_archives": False,
"enabled": True,
}
await async_client.post("/api/v1/github-backup/config", json=create_data)
# Enable spools and archives via partial update
update_data = {
"backup_spools": True,
"backup_archives": True,
}
response = await async_client.patch("/api/v1/github-backup/config", json=update_data)
assert response.status_code == 200
result = response.json()
assert result["backup_spools"] is True
assert result["backup_archives"] is True
# Other values preserved
assert result["backup_kprofiles"] is True
assert result["backup_settings"] is False
@pytest.mark.asyncio
@pytest.mark.integration
async def test_delete_config(self, async_client: AsyncClient):