Skip to content

Commit abf553d

Browse files
committed
Add more tests
1 parent bb36687 commit abf553d

File tree

9 files changed

+49
-13
lines changed

9 files changed

+49
-13
lines changed

.travis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
language: python
22
python:
3-
- "3.5"
4-
install: "pip install -r requirements.conf"
3+
- '3.5'
4+
install: pip install -r requirements.conf
55
script: python manage.py test
6+
deploy:
7+
provider: pypi
8+
user: Solleks
9+
password:
10+
secure: irXWJnMvz8xoOo7N9p8nac2wyHB8x5J0mAo9NvfX+Jv6T3+KfmAOOLMYoMBhmtxlc60tQV9rkUIG2+GDQoWK0gQXIumPfChBKELWfz4d5D73q/NHgnsiwGP4T4SM3ow3Z3uKJFLe20R4jxILwCbBQQmZ2vZoeGOJpEsGYj+bhsHNGRx5mb/Gtk2X0+tFA5cZsd1FMvnOige89E5SQds8QI//k+eErpgk0KORBzhOGDbgrdAJWcNOA2wFZIrqgMZyjZ+NhFXAyxS7BzWM8zwfFUWr5890GphH8igP/PQIvbtjCMu+x8kLMQr6S8RmeDFka6POHCYaLQOoGOVo4/r9+aVAXFd+Js+caJcmo+TWSqb1gy+mNzch1OHHGVz8WRbpvHSwzYCd35x5ScVQJqNVB2Cs4w3W/7yuoCRNvXXU/bZptVwQnukFUvlBA/2KidsXHCVPu+psFpN6r5FVKRtcyZgPW86dAqEqUqPezVYizIEXVEFpMv1EXz8zpb3rafow75sSSKz8qADu24Q4LCBkQaDyStrAw0ldyLBf3rRVZGtgeFtp3EWkhY3NCzsNPfd6AWXN3xqIcNo3n9LmzX2CTKUzJT1Z5NzaQcIDBHDTSWQrIKKMZ1aEWf4t3OZO9ehEGnYIHxesuPCggT1lfysFylHVJo+GwgId1otF53Ptg4M=
11+
on:
12+
branch: production

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ By default server is unblocked
4141

4242
Usage
4343
-----
44-
You save your django SECRET_KEY from settings
44+
You need to save your django SECRET_KEY from settings first
4545
```
4646
SECRET_KEY = '...
4747
```

django_dev_protector/tests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import json
2+
import os
3+
24
from django.test import TestCase, Client
35
from django.conf import settings
46

57
import django_dev_protector.settings
8+
from .settings import PROTECT_STATUS_VARIABLE
69
from django_dev_protector.setup import get_status
710

811

@@ -18,6 +21,15 @@ def test_block_the_server(self):
1821
}), content_type='application/json')
1922
self.assertEqual(get_status(), 'True')
2023

24+
def test_is_server_blocked(self):
25+
response = self.client.post('/django_dev_protector/', json.dumps({
26+
'key': settings.SECRET_KEY,
27+
'status': True
28+
}), content_type='application/json')
29+
response = self.client.get('/')
30+
self.assertEqual(get_status(), 'True')
31+
self.assertContains(response, 'The work was not paid.')
32+
2133
def test_unblock_the_server(self):
2234
"""
2335
Unblocks server by request
@@ -27,3 +39,13 @@ def test_unblock_the_server(self):
2739
'status': False
2840
}), content_type='application/json')
2941
self.assertEqual(get_status(), 'False')
42+
self.assertEqual(os.environ[PROTECT_STATUS_VARIABLE], 'False')
43+
44+
def test_is_server_unblocked(self):
45+
response = self.client.post('/django_dev_protector/', json.dumps({
46+
'key': settings.SECRET_KEY,
47+
'status': False
48+
}), content_type='application/json')
49+
response = self.client.get('/')
50+
self.assertEqual(get_status(), 'False')
51+
self.assertContains(response, 'works!')

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55
if __name__ == "__main__":
6-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_app.settings")
77
try:
88
from django.core.management import execute_from_command_line
99
except ImportError:
File renamed without changes.

tests/settings.py renamed to test_app/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
'django.middleware.clickjacking.XFrameOptionsMiddleware',
3737
]
3838

39-
ROOT_URLCONF = 'tests.urls'
39+
ROOT_URLCONF = 'test_app.urls'
4040

4141
TEMPLATES = [
4242
{
@@ -54,7 +54,7 @@
5454
},
5555
]
5656

57-
WSGI_APPLICATION = 'tests.wsgi.application'
57+
WSGI_APPLICATION = 'test_app.wsgi.application'
5858

5959

6060
DATABASES = {

test_app/urls.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.http import JsonResponse
2+
from django.conf.urls import url
3+
from django.contrib import admin
4+
5+
6+
def index(request):
7+
return JsonResponse({'site': 'works!'})
8+
9+
10+
urlpatterns = [
11+
url(r'^admin/', admin.site.urls),
12+
url(r'^$', index)
13+
]

tests/wsgi.py renamed to test_app/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
from django.core.wsgi import get_wsgi_application
1313

14-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_app.settings")
1515

1616
application = get_wsgi_application()

tests/urls.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)