Skip to content

Commit

Permalink
Merge pull request #69 from graingert/fix-travis
Browse files Browse the repository at this point in the history
travis build is broken on develop
  • Loading branch information
ierror authored Sep 19, 2018
2 parents 55c1ec0 + c8be839 commit c6af195
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 25 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
sudo: false
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"

- "pypy"
- "pypy3"
matrix:
include:
- language: python
python: "3.7"
dist: xenial
sudo: true

install:
- nvm install --lts
- nvm use --lts
- pip install -q tox coverage coveralls tox-travis
- mkdir travis-phantomjs
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
- export PATH=$PWD/travis-phantomjs:$PATH

script:
- coverage erase
Expand All @@ -26,6 +27,8 @@ after_success:
- coverage combine
- coveralls

cache: pip

notifications:
email:
- [email protected]
17 changes: 13 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ _________
Thank you `kavdev <https://github.com/kavdev>`_

0.8.1
Fix: The tests folder of the `#53 <https://github.com/ierror/django-js-reverse/issues/53>`_ was still present in the build. => Added cleanup to the release make command.
Fix: The tests folder of the `#53 <https://github.com/ierror/django-js-reverse/issues/53>`__ was still present in the build. => Added cleanup to the release make command.

0.8.0
New: Support for Django 2.0: `#58 <https://github.com/ierror/django-js-reverse/issues/58>`_
Thank you `wlonk <https://github.com/wlonk>`_

Fix: `#53 <https://github.com/ierror/django-js-reverse/issues/53>`_ - Don't install the tests folder as a separate folder. Moved inside the django_js_reverse namespace.
Fix: `#53 <https://github.com/ierror/django-js-reverse/issues/53>`__ - Don't install the tests folder as a separate folder. Moved inside the django_js_reverse namespace.

0.7.3
New: Support for Django 1.10
Expand Down Expand Up @@ -133,14 +133,18 @@ Usage as static file
--------------------

First generate static file by

::

./manage.py collectstatic_js_reverse

If you change some urls or add an app and want to update the reverse.js file,
run the command again.

After this add the file to your template

::

<script src="{% static 'django_js_reverse/js/reverse.js' %}"></script>


Expand Down Expand Up @@ -180,6 +184,9 @@ or, if you are using Django > 1.5
Usage as template tag
_____________________


::

{% load js_reverse %}

<script type="text/javascript" charset="utf-8">
Expand Down Expand Up @@ -253,16 +260,18 @@ To exclude any namespaces from the generated javascript file, add them to the `J

If you want to include only specific namespaces add them to the `JS_REVERSE_INCLUDE_ONLY_NAMESPACES` setting
tips:
* Use "" (empty string) for urls without namespace
* Use "foo\0" to include urls just from "foo" namaspace and not from any subnamespaces (e.g. "foo:bar")
* Use "" (empty string) for urls without namespace
* Use "foo\0" to include urls just from "foo" namaspace and not from any subnamespaces (e.g. "foo:bar")

::

JS_REVERSE_INCLUDE_ONLY_NAMESPACES = ['poll', 'calendar', ...]

If you run your application under a subpath, the collectstatic_js_reverse needs to take care of this.
Define the prefix in your django settings:

::

JS_REVERSE_SCRIPT_PREFIX = '/myprefix/'

By default collectstatic_js_reverse writes its output (reverse.js) to your project's STATIC_ROOT.
Expand Down
22 changes: 11 additions & 11 deletions django_js_reverse/tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import json
import os
import re
import subprocess
import sys
import unittest

Expand All @@ -13,7 +16,6 @@
from django.template import Context, RequestContext, Template
from django.utils.encoding import smart_str
from helper import is_django_ver_gte_2
from selenium.webdriver.phantomjs.webdriver import WebDriver
from utils import script_prefix

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..') + os.sep)
Expand All @@ -23,28 +25,26 @@
from django.test.client import Client # noqa: E402 isort:skip
from django.test.utils import override_settings # noqa: E402 isort:skip


class AbstractJSReverseTestCase(object):
client = Client()
selenium = WebDriver()

@classmethod
def setUpClass(cls):
if hasattr(django, 'setup'):
# for django >= 1.7
django.setup()
cls.selenium = WebDriver()
super(AbstractJSReverseTestCase, cls).setUpClass()

@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super(AbstractJSReverseTestCase, cls).tearDownClass()

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)
script = '{}return {};'.format(smart_str(response.content), url_call)
module = 'console.log(new Function({})());'.format(json.dumps(script))
stdout = (
subprocess
.check_output(['node', '-e', module.encode('utf8')])
.decode('utf8')
)
self.assertEqual(re.sub(r'\n$', '', stdout), expected_url)


@override_settings(ROOT_URLCONF='django_js_reverse.tests.test_urls')
Expand Down
Empty file modified setup.py
100644 → 100755
Empty file.
19 changes: 14 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
[tox]
envlist =
py27-django{111,110,19,18,17,16,15},
py{py,27}-django{111,110,19,18,17,16,15},
py34-django{20,111,110,19,18,17,16,15},
py35-django{20,111,110,19,18},
py36-django{20,111,110,19,18},
py37-django{20,111,110,19,18},
py{py3,35,36,37}-django{21,20,111,110,19,18},
check

[testenv]
usedevelop = true
pip_pre = true
commands = coverage run -p django_js_reverse/tests/unit_tests.py
deps=
coverage==4.5.1
selenium==2.52.0
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
Expand All @@ -21,3 +19,14 @@ deps=
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2


[testenv:check]
commands = ./setup.py check --restructuredtext --strict --metadata
deps =
docutils==0.14

[travis]
python =
3.7: py37, check

0 comments on commit c6af195

Please sign in to comment.