mirror of
https://github.com/boostorg/website-v2.git
synced 2026-01-19 04:42:17 +00:00
Fix failing test
This commit is contained in:
1
Makefile
1
Makefile
@@ -89,7 +89,6 @@ rebuild:
|
||||
@echo "Rebuilding local docker images..."
|
||||
docker-compose kill
|
||||
docker-compose rm -f web
|
||||
docker-compose rm -f worker
|
||||
DOCKER_BUILDKIT=1 docker-compose build --force-rm web
|
||||
|
||||
.PHONY: shell
|
||||
|
||||
@@ -5,21 +5,24 @@ from django.db import models
|
||||
|
||||
|
||||
class VersionFile(models.Model):
|
||||
Unix = 'Unix'
|
||||
Windows = 'Windows'
|
||||
Unix = "Unix"
|
||||
Windows = "Windows"
|
||||
OPERATING_SYSTEM_CHOICES = (
|
||||
(Unix, 'Unix'),
|
||||
(Windows, 'Windows'),
|
||||
(Unix, "Unix"),
|
||||
(Windows, "Windows"),
|
||||
)
|
||||
checksum = models.CharField(max_length=64, unique=True, default=None)
|
||||
file = models.FileField(upload_to="uploads/")
|
||||
operating_system = models.CharField(
|
||||
choices=OPERATING_SYSTEM_CHOICES, max_length=15, null=False, blank=False)
|
||||
|
||||
choices=OPERATING_SYSTEM_CHOICES, max_length=15, null=False, blank=False
|
||||
)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.file is not None:
|
||||
if self.checksum is None:
|
||||
self.checksum = hashlib.sha256(self.file.name.encode("utf-8")).hexdigest()
|
||||
self.checksum = hashlib.sha256(
|
||||
self.file.name.encode("utf-8")
|
||||
).hexdigest()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
@@ -28,4 +31,4 @@ class Version(models.Model):
|
||||
max_length=256, null=False, blank=False, help_text="Version name"
|
||||
)
|
||||
files = models.ManyToManyField(VersionFile)
|
||||
release_date = models.DateField(auto_now=False, auto_now_add=False)
|
||||
release_date = models.DateField(auto_now=False, auto_now_add=False)
|
||||
|
||||
@@ -23,7 +23,9 @@ class VersionViewTests(TestCase):
|
||||
self.version_manager = UserFactory()
|
||||
self.version_file1 = VersionFileFactory()
|
||||
self.version_file2 = VersionFileFactory()
|
||||
self.version = VersionFactory.create(files=(self.version_file1, self.version_file2))
|
||||
self.version = VersionFactory.create(
|
||||
files=(self.version_file1, self.version_file2)
|
||||
)
|
||||
|
||||
def test_list_version(self):
|
||||
"""
|
||||
@@ -41,7 +43,6 @@ class VersionViewTests(TestCase):
|
||||
self.assertIn("checksum", response.data[0])
|
||||
self.assertIn("operating_system", response.data[0])
|
||||
|
||||
|
||||
def test_create(self):
|
||||
image = Image.new("RGB", (100, 100))
|
||||
|
||||
@@ -50,13 +51,13 @@ class VersionViewTests(TestCase):
|
||||
|
||||
tmp_file.seek(0)
|
||||
from django.core.files import File as DjangoFile
|
||||
file_obj = DjangoFile(open(tmp_file.name, mode='rb'), name="tmp_file")
|
||||
version_file = VersionFile.objects.create(file=file_obj, operating_system="Windows")
|
||||
|
||||
payload = {
|
||||
"file": file_obj,
|
||||
"operating_system": "Windows"
|
||||
}
|
||||
file_obj = DjangoFile(open(tmp_file.name, mode="rb"), name="tmp_file")
|
||||
version_file = VersionFile.objects.create(
|
||||
file=file_obj, operating_system="Windows"
|
||||
)
|
||||
|
||||
payload = {"file": file_obj, "operating_system": "Windows"}
|
||||
|
||||
# Does API work without auth?
|
||||
response = self.client.post(
|
||||
@@ -91,7 +92,7 @@ class VersionViewTests(TestCase):
|
||||
try:
|
||||
with transaction.atomic():
|
||||
response = self.client.post(
|
||||
reverse("versions-list"), data=payload, format="multipart"
|
||||
reverse("version-files-list"), data=payload, format="multipart"
|
||||
)
|
||||
self.response_201(response)
|
||||
except IntegrityError:
|
||||
|
||||
Reference in New Issue
Block a user