Multi-platform: support multiple files per version #201
Binary file not shown.
@ -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']
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user