-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set a default max length to 1024 for URLFields
- Loading branch information
KhaledBousrih
committed
Jun 19, 2023
1 parent
ede4af0
commit 1d5f040
Showing
6 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
### Changed | ||
|
||
- nothing changed | ||
- Set a default max length to 1024 for URLFields | ||
|
||
### Removed | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.19 on 2023-06-19 13:53 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('concrete', '0012_auto_20221115_0644'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='project', | ||
name='storage_url', | ||
field=models.URLField(blank=True, max_length=1024, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.test import TestCase | ||
from concrete_datastore.concrete.models import Project | ||
from django.db import DataError | ||
|
||
|
||
class UrlValidationTestCase(TestCase): | ||
#: URL length validator is 1024 | ||
def test_nominal_case(self): | ||
url = "http://domain.ext/" + "a/" * 491 | ||
self.assertEqual(len(url), 1000) | ||
# 1000 < 1024 | ||
self.assertEqual(Project.objects.count(), 0) | ||
project = Project.objects.create(storage_url=url) | ||
self.assertEqual(Project.objects.count(), 1) | ||
self.assertEqual(len(project.storage_url), 1000) | ||
|
||
def test_validation_error(self): | ||
url = "http://domain.ext/" + "a/" * 991 | ||
self.assertEqual(len(url), 2000) | ||
# 2000 > 1024 | ||
self.assertEqual(Project.objects.count(), 0) | ||
with self.assertRaises(DataError): | ||
Project.objects.create(storage_url=url) |