Skip to content

Commit

Permalink
tox
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Gibson committed May 9, 2017
1 parent 8b48cb9 commit 9503d00
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions livesync/tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from unittest import TestCase
# from django.test import TestCase
from mock import Mock, PropertyMock, patch
from livesync.core.middleware import DjangoLiveSyncMiddleware
# from django.conf import settings


class LiveSyncMiddlewareTestCase(TestCase):
def setUp(self):
self.mocked_response = Mock()
self.get_response = Mock(return_value=self.mocked_response)
self.middleware = DjangoLiveSyncMiddleware(self.get_response)
self.mock_content_property = PropertyMock(return_value="<body></body>")
self.mock_content_property = PropertyMock(return_value=b"<body></body>")
type(self.mocked_response).content = self.mock_content_property

@patch('livesync.core.middleware.settings.DEBUG', True)
Expand All @@ -20,7 +20,7 @@ def test_middleware_injects_js_file_correctly(self):
# assert

self.mock_content_property.assert_called()
self.assertTrue("<script src='/static/livesync.js'></script>" in self.mock_content_property.call_args[0][0])
self.assertTrue(b"<script src='/static/livesync.js'></script>" in self.mock_content_property.call_args[0][0])

@patch('livesync.core.middleware.settings.DEBUG', True)
@patch('django.conf.settings.DEBUG', True)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ coverage==4.3.4
Django==1.11
mock==2.0.0
nose2==0.6.5
tox==2.7.0
2 changes: 2 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import sys

import nose2
import django
from django.conf import settings


if __name__ == '__main__':
settings.configure()
django.setup()
settings.BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
settings.DJANGO_LIVESYNC = {'PORT': 9001, 'HOST': '127.0.0.1'}
result = nose2.discover()
Expand Down
15 changes: 15 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tox]
envlist =
py33-django8
py36-django11
py{27,34,35}-django{8,9,10,11}

[testenv]
deps=
mock
nose2
django8: Django==1.8
django9: Django==1.9
django10: Django==1.10
django11: Django==1.11
commands=python runtests.py

0 comments on commit 9503d00

Please sign in to comment.