Skip to content

Commit

Permalink
Integrated PR #37
Browse files Browse the repository at this point in the history
  • Loading branch information
ierror committed Mar 6, 2016
1 parent a0cbd88 commit 9607b32
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Expand Up @@ -3,6 +3,9 @@

Thank you `mjnaderi <https://github.com/ierror/django-js-reverse/pull/36>`_

New: Support for Django 1.9

Thank you `mjnaderi <https://github.com/ierror/django-js-reverse/pull/37>`_

0.6.1
Refactored: Separate the view functionality from the JS generation
Expand Down
11 changes: 11 additions & 0 deletions README.rst
Expand Up @@ -58,6 +58,10 @@ _________

Thank you `mjnaderi <https://github.com/ierror/django-js-reverse/pull/36>`_

New: Support for Django 1.9

Thank you `mjnaderi <https://github.com/ierror/django-js-reverse/pull/37>`_

0.6.1
Refactored: Separate the view functionality from the JS generation

Expand Down Expand Up @@ -238,6 +242,13 @@ You can change the output path:
JS_REVERSE_OUTPUT_PATH = 'some_path'


Running the test suite
----------------------

::

make test

License
-------

Expand Down
18 changes: 10 additions & 8 deletions tests/unit_tests.py
Expand Up @@ -10,28 +10,27 @@
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django
import unittest
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.template import RequestContext
from django.test import TestCase
from django.test.client import Client
from django.test.utils import override_settings
import unittest
from django.utils.encoding import smart_str

from selenium.webdriver.phantomjs.webdriver import WebDriver

from utils import script_prefix


# Raise errors on DeprecationWarnings
warnings.simplefilter('error', DeprecationWarning)


class AbstractJSReverseTestCase(object):
client = None
urls = 'tests.test_urls'
client = Client()
selenium = WebDriver()

@classmethod
def setUpClass(cls):
Expand All @@ -46,15 +45,13 @@ def tearDownClass(cls):
cls.selenium.quit()
super(AbstractJSReverseTestCase, cls).tearDownClass()

def setUp(self):
self.client = Client()

def assertEqualJSUrlEval(self, url_call, expected_url):
response = self.client.post('/jsreverse/')
self.assertEqual(self.selenium.execute_script('%s return %s;' % (smart_str(response.content), url_call)),
expected_url)


@override_settings(ROOT_URLCONF='tests.test_urls')
class JSReverseViewTestCaseMinified(AbstractJSReverseTestCase, TestCase):
def test_view_no_url_args(self):
self.assertEqualJSUrlEval('Urls.test_no_url_args()', '/test_no_url_args/')
Expand Down Expand Up @@ -136,6 +133,7 @@ def test_duplicate_argcount(self):


@override_settings(JS_REVERSE_JS_MINIFY=False)
@override_settings(ROOT_URLCONF='tests.test_urls')
class JSReverseViewTestCaseNotMinified(JSReverseViewTestCaseMinified):
def test_minification(self):
js_not_minified = smart_str(self.client.post('/jsreverse/').content)
Expand All @@ -144,6 +142,7 @@ def test_minification(self):
self.assertTrue(len(js_minified) < len(js_not_minified))


@override_settings(ROOT_URLCONF='tests.test_urls')
class JSReverseViewTestCaseGlobalObjectName(JSReverseViewTestCaseMinified):
def test_global_object_name_default(self):
js_content = smart_str(self.client.post('/jsreverse/').content)
Expand All @@ -160,6 +159,7 @@ def test_global_object_name_change_invalid_identifier(self):
self.client.post('/jsreverse/')


@override_settings(ROOT_URLCONF='tests.test_urls')
class JSReverseStaticFileSaveTest(AbstractJSReverseTestCase, TestCase):
def test_reverse_js_file_save(self):
call_command('collectstatic_js_reverse')
Expand Down Expand Up @@ -206,14 +206,16 @@ def test_reverse_js_file_save_with_output_path_option(self):
try:
call_command('collectstatic_js_reverse')
except ImproperlyConfigured:
self.fail('should not raise ImproperlyConfigured exception if STATIC_ROOT is not set and JS_REVERSE_OUTPUT_PATH is set')
self.fail(
'should not raise ImproperlyConfigured exception if STATIC_ROOT is not set and JS_REVERSE_OUTPUT_PATH is set')

def test_script_prefix(self):
script_prefix = '/test/foo/bar/'
with override_settings(JS_REVERSE_SCRIPT_PREFIX=script_prefix):
self.assertEqualJSUrlEval('Urls.test_no_url_args()', '{0}test_no_url_args/'.format(script_prefix))


@override_settings(ROOT_URLCONF='tests.test_urls')
class JSReverseTemplateTagTest(AbstractJSReverseTestCase, TestCase):
def test_tpl_tag_with_request_in_contect(self):
from django_js_reverse.templatetags.js_reverse import js_reverse_inline
Expand Down
16 changes: 2 additions & 14 deletions tox.ini
Expand Up @@ -2,7 +2,7 @@
envlist =
py26-django16, py26-django15,
py27-django19, py27-django18, py27-django17, py27-django16, py27-django15,
py33-django19, py33-django18, py33-django17, py33-django16, py33-django15,
py33-django18, py33-django17, py33-django16, py33-django15,
py34-django19, py34-django18, py34-django17, py34-django16, py34-django15,
;pypy25-django18, pypy25-django17, pypy25-django16, pypy25-django15,
;pypy3-24-django18, pypy3-24-django17, pypy3-24-django16, pypy3-24-django15
Expand All @@ -12,7 +12,7 @@ usedevelop = true
pip_pre = true
commands = coverage run -p tests/unit_tests.py
deps=coverage==3.7.1
selenium==2.45.0
selenium==2.52.0

[testenv:py27-django19]
basepython = python2.7
Expand Down Expand Up @@ -56,12 +56,6 @@ deps =
Django>=1.5,<1.6
{[testenv]deps}

[testenv:py33-django19]
basepython = python3.3
deps =
Django>=1.9,<1.10
{[testenv]deps}

[testenv:py33-django18]
basepython = python3.3
deps =
Expand Down Expand Up @@ -116,12 +110,6 @@ deps =
Django>=1.5,<1.6
{[testenv]deps}

[testenv:pypy25-django19]
basepython = pypy
deps =
Django>=1.9,<1.10
{[testenv]deps}

[testenv:pypy25-django18]
basepython = pypy
deps =
Expand Down

0 comments on commit 9607b32

Please sign in to comment.