diff options
| author | Vladg90 | 2014-04-15 13:58:02 +0300 | 
|---|---|---|
| committer | Vladg90 | 2014-04-15 13:58:02 +0300 | 
| commit | fa177590906de6fdef3c51d4c4acf27af9b19c4d (patch) | |
| tree | 1b8f3c9fbf584efa5d5bdd07ded63b1995f71863 | |
| parent | 66a6ab9941aafdb63783e4617619f1d82efaa4d5 (diff) | |
| download | django-brevisurl-fa177590906de6fdef3c51d4c4acf27af9b19c4d.tar.bz2 | |
Add URL shortening time duration tests
| -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)   +     | 
