diff options
Diffstat (limited to 'brevisurl/tests/backends/test_local.py')
| -rw-r--r-- | brevisurl/tests/backends/test_local.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/brevisurl/tests/backends/test_local.py b/brevisurl/tests/backends/test_local.py index 4577376..8ddc7ed 100644 --- a/brevisurl/tests/backends/test_local.py +++ b/brevisurl/tests/backends/test_local.py @@ -1,5 +1,6 @@ +from django.db import transaction from django.core.exceptions import ValidationError -from django.test import TestCase +from django.test import TestCase, TransactionTestCase from django.core.validators import URLValidator import brevisurl.settings @@ -7,6 +8,9 @@ from brevisurl import get_connection from brevisurl.models import ShortUrl from brevisurl.backends.local import TokensExhaustedError +import random + + class TestLocalBrevisUrlBackend(TestCase): @@ -128,4 +132,21 @@ class TestLocalBrevisUrlBackend(TestCase): original_url = 'http://www.codescale.net/' connection = get_connection('brevisurl.backends.local.BrevisUrlBackend', domain='http://test.com/d/') short_url = connection.shorten_url(original_url) - self.assertRegexpMatches(short_url.shortened_url, r'^http://test\.com/d/[^/]{5}$')
\ No newline at end of file + self.assertRegexpMatches(short_url.shortened_url, r'^http://test\.com/d/[^/]{5}$') + +class TestDuration(TransactionTestCase): + + def setUp(self): + self.connection = get_connection('brevisurl.backends.local.BrevisUrlBackend') + + def test_shorten_urls_duration(self): + for i in range(0, 10000): + url = 'http://www.codescale.net/%s' % random.getrandbits(30) + self.connection.shorten_url(url) + + @transaction.commit_on_success + def test_shorten_urls_duration_commit_on_success(self): + for i in range(0, 10000): + url = 'http://www.codescale.net/%s' % random.getrandbits(30) + self.connection.shorten_url(url) + |
