feat: a link in download section

This commit is contained in:
mohamad
2026-06-07 17:41:41 +03:30
parent cbc49cd8ae
commit 33b3477176
17 changed files with 215 additions and 17 deletions
+27
View File
@@ -155,6 +155,33 @@ class ArticleModelTest(TestCase):
article.full_clean()
class ReleaseFileStorageTest(TestCase):
def test_save_overwrites_existing_release_file(self):
from django.core.files.uploadedfile import SimpleUploadedFile
from apps.products.models import MainProduct, SubProductVersion
main = MainProduct.objects.create(
name="Storage Test",
short_description="s",
description="d",
)
version = SubProductVersion.objects.create(
main_product=main,
version="1.0",
windows_download_file=SimpleUploadedFile("setup.exe", b"v1"),
is_active=True,
)
version.windows_download_file.save(
"setup.exe",
SimpleUploadedFile("setup.exe", b"v2"),
save=True,
)
version.refresh_from_db()
with version.windows_download_file.open("rb") as handle:
self.assertEqual(handle.read(), b"v2")
class SubProductVersionModelTest(TestCase):
def setUp(self):
self.main_product = MainProduct.objects.create(
+1 -2
View File
@@ -216,6 +216,7 @@ class SubProductOlderVersionsViewTest(ProductViewsSetup):
self.assertTrue(response.context["show_releases_section"])
@override_settings(MEDIA_ROOT=settings.BASE_DIR / "test_media_releases")
class ReleaseAssetDownloadViewTest(ProductViewsSetup):
def test_uploaded_file_download(self):
release_file = SimpleUploadedFile("setup.exe", b"binary-payload")
@@ -277,7 +278,6 @@ class ReleaseAssetDownloadViewTest(ProductViewsSetup):
)
self.assertEqual(self.client.get(url).status_code, 404)
@override_settings(MEDIA_ROOT=settings.BASE_DIR / "test_media_releases")
def test_clearing_file_removes_from_disk(self):
version = SubProductVersion.objects.create(
main_product=self.main_product,
@@ -294,7 +294,6 @@ class ReleaseAssetDownloadViewTest(ProductViewsSetup):
self.assertEqual(version.windows_download_filename, "")
self.assertFalse(os.path.exists(stored_path))
@override_settings(MEDIA_ROOT=settings.BASE_DIR / "test_media_releases")
def test_deleting_version_removes_files_from_disk(self):
version = SubProductVersion.objects.create(
main_product=self.main_product,