Multi-platform: support multiple files per version #201

Merged
Oleg-Komarov merged 43 commits from multi-os into main 2024-07-09 16:27:46 +02:00
3 changed files with 13 additions and 3 deletions
Showing only changes of commit 666e2b0fb8 - Show all commits

View File

@ -605,6 +605,7 @@ class MultiPlatformUploadTest(TestCase):
).extension
file_linux = TEST_FILES_DIR / 'addon-with-split-platforms-linux.zip'
file_windows = TEST_FILES_DIR / 'addon-with-split-platforms-windows.zip'
file_no_platforms = TEST_FILES_DIR / 'addon-without-platforms-for-split-test.zip'
self.client.force_login(extension.authors.all()[0])
with open(file_linux, 'rb') as fp:
@ -638,6 +639,17 @@ class MultiPlatformUploadTest(TestCase):
self.assertEqual(extension.latest_version.files.count(), 2)
self.assertEqual(extension.latest_version.platforms.count(), 2)
# can't upload a platform-agnostic file
with open(file_no_platforms, 'rb') as fp:
response = self.client.post(
extension.get_new_version_url(),
{'source': fp, 'agreed_with_terms': True},
)
self.assertEqual(response.status_code, 200)
extension.refresh_from_db()
self.assertEqual(extension.latest_version.files.count(), 2)
self.assertEqual(extension.latest_version.platforms.count(), 2)
class DraftsWarningTest(TestCase):
fixtures = ['licenses']

View File

@ -174,13 +174,11 @@ class ExtensionVersionManifestValidator:
if not extension_to_be_updated:
return
# check for duplicates in database
manifest_version = manifest.get('version')
version = extension_to_be_updated.versions.filter(version=manifest_version).first()
if not version:
return
# check for platforms
# TODO test coverage
# for existing versions only submissions for remaining platfroms are valid
remaining_platforms = version.get_remaining_platforms()
if platforms := files.models.File.parse_platforms_from_manifest(manifest):
if diff := set(platforms) - remaining_platforms: