Fix #241: 500 Error when submitting extension without "type" #242

Merged
Dalai Felinto merged 3 commits from fix-241-missing-type into main 2024-08-29 13:03:57 +02:00
Showing only changes of commit d6a3df95e1 - Show all commits

View File

@ -47,7 +47,7 @@ class CreateFileTest(TestCase):
"id": "blender_kitsu", "id": "blender_kitsu",
"version": "0.1.5", "version": "0.1.5",
} }
self.file = self._create_file_from_data("blender_kitsu_1.5.0.zip", file_data, self.user) self.file = self._create_file_from_data("blender_kitsu_1.5.0.zip", file_data)
def tearDown(self): def tearDown(self):
super().tearDown() super().tearDown()
@ -61,7 +61,7 @@ class CreateFileTest(TestCase):
status=File.STATUSES.APPROVED, status=File.STATUSES.APPROVED,
) )
def _create_file_from_data(self, filename, file_data, user): def _create_file_from_data(self, filename, file_data):
output_path = os.path.join(self.temp_directory, filename) output_path = os.path.join(self.temp_directory, filename)
manifest_path = os.path.join(self.temp_directory, "blender_manifest.toml") manifest_path = os.path.join(self.temp_directory, "blender_manifest.toml")
combined_meta_data = META_DATA.copy() combined_meta_data = META_DATA.copy()
@ -105,7 +105,7 @@ class ValidateManifestTest(CreateFileTest):
"id": "id-with-hyphens", "id": "id-with-hyphens",
} }
bad_file = self._create_file_from_data("theme.zip", file_data, self.user) bad_file = self._create_file_from_data("theme.zip", file_data)
with open(bad_file, 'rb') as fp: with open(bad_file, 'rb') as fp:
response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True}) response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True})
@ -123,7 +123,7 @@ class ValidateManifestTest(CreateFileTest):
"id": "id with spaces", "id": "id with spaces",
} }
bad_file = self._create_file_from_data("theme.zip", file_data, self.user) bad_file = self._create_file_from_data("theme.zip", file_data)
with open(bad_file, 'rb') as fp: with open(bad_file, 'rb') as fp:
response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True}) response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True})
@ -146,7 +146,7 @@ class ValidateManifestTest(CreateFileTest):
"version": "0.1.5", "version": "0.1.5",
} }
extension_file = self._create_file_from_data("theme.zip", kitsu_1_5, self.user) extension_file = self._create_file_from_data("theme.zip", kitsu_1_5)
with open(extension_file, 'rb') as fp: with open(extension_file, 'rb') as fp:
response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True}) response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True})
@ -170,7 +170,7 @@ class ValidateManifestTest(CreateFileTest):
"version": "0.1.5", "version": "0.1.5",
} }
extension_file = self._create_file_from_data("theme.zip", kitsu_1_5, self.user) extension_file = self._create_file_from_data("theme.zip", kitsu_1_5)
with open(extension_file, 'rb') as fp: with open(extension_file, 'rb') as fp:
response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True}) response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True})
@ -194,7 +194,7 @@ class ValidateManifestTest(CreateFileTest):
"version": "0.1.6", "version": "0.1.6",
} }
extension_file = self._create_file_from_data("theme.zip", non_kitsu_1_6, self.user) extension_file = self._create_file_from_data("theme.zip", non_kitsu_1_6)
with open(extension_file, 'rb') as fp: with open(extension_file, 'rb') as fp:
response = self.client.post( response = self.client.post(
version.extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True} version.extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True}
@ -221,9 +221,7 @@ class ValidateManifestTest(CreateFileTest):
"version": version.version, "version": version.version,
} }
extension_file = self._create_file_from_data( extension_file = self._create_file_from_data("kitsu_clash.zip", kitsu_version_clash)
"kitsu_clash.zip", kitsu_version_clash, self.user
)
with open(extension_file, 'rb') as fp: with open(extension_file, 'rb') as fp:
response = self.client.post( response = self.client.post(
version.extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True} version.extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True}
@ -262,7 +260,7 @@ class ValidateManifestTest(CreateFileTest):
"version": '0.1.6', "version": '0.1.6',
} }
extension_file = self._create_file_from_data("updated_kitsu.zip", updated_kitsu, self.user) extension_file = self._create_file_from_data("updated_kitsu.zip", updated_kitsu)
with open(extension_file, 'rb') as fp: with open(extension_file, 'rb') as fp:
response = self.client.post( response = self.client.post(
version.extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True} version.extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True}
@ -284,7 +282,7 @@ class ValidateManifestTest(CreateFileTest):
"id": "id-with-hyphens", "id": "id-with-hyphens",
} }
bad_file = self._create_file_from_data("theme.zip", file_data, self.user) bad_file = self._create_file_from_data("theme.zip", file_data)
with open(bad_file, 'rb') as fp: with open(bad_file, 'rb') as fp:
response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True}) response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True})
@ -303,7 +301,7 @@ class ValidateManifestTest(CreateFileTest):
"name": "Name. - With Extra spaces and other characters Ж", "name": "Name. - With Extra spaces and other characters Ж",
} }
extension_file = self._create_file_from_data("theme.zip", file_data, self.user) extension_file = self._create_file_from_data("theme.zip", file_data)
with open(extension_file, 'rb') as fp: with open(extension_file, 'rb') as fp:
response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True}) response = self.client.post(self.submit_url, {'source': fp, 'agreed_with_terms': True})
@ -782,7 +780,7 @@ class VersionPermissionsTest(CreateFileTest):
} }
# Step 1: submit the file # Step 1: submit the file
extension_file = self._create_file_from_data("kitsu-0.1.6.zip", new_kitsu, self.user) extension_file = self._create_file_from_data("kitsu-0.1.6.zip", new_kitsu)
with open(extension_file, 'rb') as fp: with open(extension_file, 'rb') as fp:
response = self.client.post( response = self.client.post(
extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True} extension.get_new_version_url(), {'source': fp, 'agreed_with_terms': True}