Uninen / kabinettiorg (http://kabinetti.org/)

The source of kabinetti.org Web site (to come).

Clone this repository (size: 4.9 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/Uninen/kabinettiorg/
commit 21: f05dabe2ddaa
parent 20: 0334adf15de2
branch: default
Added urls and tests for api app
Ville Säävuori / Uninen
12 months ago

Changed (Δ1.4 KB):

raw changeset »

apps/api/models.py (null-size change)

apps/api/tests.py (34 lines added, 0 lines removed)

apps/api/urls.py (7 lines added, 0 lines removed)

kabinettiorg/settings/kabinettibuntu.py (3 lines added, 1 lines removed)

kabinettiorg/settings/trinity.py (3 lines added, 1 lines removed)

kabinettiorg/urls.py (1 lines added, 2 lines removed)

Up to file-list apps/api/tests.py:

1
# -*- coding: utf-8 -*-
2
from django.test import TestCase
3
from django.contrib.auth.models import User
4
from django.conf import settings
5
6
from api.views import get_api_key_for_user
7
8
class ApiTestCase(TestCase):
9
    urls = 'api.urls'
10
    
11
    def setUp(self):
12
        self.testuser = User.objects.create_user(
13
            'samuli', 'putro@zenkkarit.rules', 'samulisala')
14
15
    def test_api_urls(self):
16
        
17
        # must be logged in
18
        response = self.client.get('/')
19
        self.failUnlessEqual(response.status_code, 302)
20
21
        # must work when logged in :)
22
        self.client.login(username='samuli', password='samulisala')
23
        response = self.client.get('/')
24
        self.failUnlessEqual(response.status_code, 200)
25
        
26
        api_key = get_api_key_for_user(self.testuser)
27
        self.assertContains(response, api_key)
28
29
        # must return 403 with no api key or without is_staff -status
30
        response = self.client.get('/export_media/')
31
        self.failUnlessEqual(response.status_code, 403)
32
        
33
        response = self.client.get('/export_media/', {'api_key': api_key})
34
        self.failUnlessEqual(response.status_code, 403)

Up to file-list apps/api/urls.py:

1
# -*- coding: utf-8 -*-
2
from django.conf.urls.defaults import *
3
4
urlpatterns = patterns('api.views',
5
    url(r'^$', 'index'),
6
    url(r'^export_media/$', 'export_media'),
7
)

Up to file-list kabinettiorg/settings/kabinettibuntu.py:

@@ -52,6 +52,7 @@ INSTALLED_APPS = (
52
52
    'lightning',
53
53
    'django_openid',
54
54
    'contacts',
55
    'api',
55
56
)
56
57
57
58
### Extra Djangosettings
@@ -66,8 +67,9 @@ FORCE_LOWERCASE_TAGS = True
66
67
DATA_ROOT = '/home/kabinettiorg/kabinettiorg/data/'
67
68
68
69
TEST_APPS = (
70
    'lightning',
69
71
    'contacts',
70
    'lightning',
72
    'api',
71
73
)
72
74
73
75
# if these are set, you can use automatic tools for fetching prod db for testing

Up to file-list kabinettiorg/settings/trinity.py:

@@ -58,6 +58,7 @@ INSTALLED_APPS = (
58
58
    'lightning',
59
59
    'django_openid',
60
60
    'contacts',
61
    'api',
61
62
)
62
63
63
64
### Extra Djangosettings
@@ -72,8 +73,9 @@ FORCE_LOWERCASE_TAGS = True
72
73
DATA_ROOT = '/home/kabinettiorg/kabinettiorg/data/'
73
74
74
75
TEST_APPS = (
76
    'lightning',
75
77
    'contacts',
76
    'lightning',
78
    'api',
77
79
)
78
80
79
81
# if these are set, you can use automatic tools for fetching prod db for testing

Up to file-list kabinettiorg/urls.py:

@@ -20,7 +20,6 @@ urlpatterns += patterns('',
20
20
    url(r'^kirjaudu/ulos/$', 'django.contrib.auth.views.logout'),
21
21
    url(r'^openid/(.*)', KabinettiConsumer()),
22
22
    url(r'kontaktit/', include('contacts.urls')),
23
    url(r'api/$', 'api.views.index'),
24
    url(r'api/export_media/$', 'api.views.export_media'),
23
    url(r'api/', include('api.urls')),
25
24
    url(r'', include('lightning.urls')),
26
25
)