Skip to content

Commit

Permalink
Increase URL field length
Browse files Browse the repository at this point in the history
  • Loading branch information
aweakley committed Mar 24, 2024
1 parent 2429a14 commit 655d734
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
13 changes: 12 additions & 1 deletion testproject/home/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,18 @@ def test_keyring_update_or_create(self):
self.assertEqual(KeyringItem.objects.count(), 1)
self.assertEqual(KeyringItem.objects.first().expiry, expiry2)

def test_keyring_update_or_create__long_url(self):
expiry = now() + datetime.timedelta(hours=1)
key = "abc123"
url = f"https://example.com/?query={ 'a' * 900 }"

KeyringItem.objects.set(
expiry=expiry,
key=key,
url=url,
)
self.assertEqual(KeyringItem.objects.count(), 1)

def test_delete_expired(self):
"""
Cache items expire by themselves, so we only need to actively
Expand All @@ -670,7 +682,6 @@ def test_delete_expired(self):
time.sleep(1)
KeyringItem.objects.clear_expired()
self.assertEqual(KeyringItem.objects.count(), 1)

# Cache items remain
for key in used_keys:
self.assertTrue(self.cache.get(key))
Expand Down
15 changes: 15 additions & 0 deletions wagtailcache/migrations/0002_increase_url_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("wagtailcache", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="keyringitem",
name="url",
field=models.URLField(max_length=1000),
),
]
2 changes: 1 addition & 1 deletion wagtailcache/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class KeyringItem(models.Model):

expiry = models.DateTimeField()
key = models.CharField(max_length=512)
url = models.URLField()
url = models.URLField(max_length=1000)

objects = KeyringItemManager()

Expand Down

0 comments on commit 655d734

Please sign in to comment.