Skip to content

Commit

Permalink
Merge pull request thauber#43 from hovel/master
Browse files Browse the repository at this point in the history
include locale files in package, tests consistency
  • Loading branch information
llazzaro committed Jan 29, 2014
2 parents 9ca1a4a + 1520f1f commit 58291a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
recursive-include docs *
recursive-include schedule/static *
recursive-include schedule/templates *
recursive-include schedule/locale *
recursive-include schedule/fixtures *.json
recursive-include project_sample *
16 changes: 10 additions & 6 deletions schedule/tests/test_perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
from schedule import utils


def default_check_perms(ob, user):
return user.is_authenticated()


def check_event_perms(ob, user):
return user.username == 'ann'

Expand Down Expand Up @@ -54,28 +50,33 @@ def _check_protected_urls(self, should_allow):

def test_event_perms(self):
# ann has event rights, bob don't
default_event_check = utils.CHECK_EVENT_PERM_FUNC
utils.CHECK_EVENT_PERM_FUNC = check_event_perms
utils.CHECK_CALENDAR_PERM_FUNC = default_check_perms

self.client.login(username='ann', password='ann')
self._check_protected_urls(should_allow=True)

self.client.login(username='bob', password='bob')
self._check_protected_urls(should_allow=False)

utils.CHECK_EVENT_PERM_FUNC = default_event_check

def test_calendar_perms(self):
# bob has calendar rights, ann don't
utils.CHECK_EVENT_PERM_FUNC = default_check_perms
default_cal_check = utils.CHECK_CALENDAR_PERM_FUNC
utils.CHECK_CALENDAR_PERM_FUNC = check_calendar_perms

self.client.login(username='ann', password='ann')
self._check_protected_urls(should_allow=False)

self.client.login(username='bob', password='bob')
self._check_protected_urls(should_allow=True)
utils.CHECK_CALENDAR_PERM_FUNC = default_cal_check

def test_calendar_and_event_perms(self):
# two mutually exclusive functions, nor ann or bob has rights to access protected views
default_event_check = utils.CHECK_EVENT_PERM_FUNC
default_cal_check = utils.CHECK_CALENDAR_PERM_FUNC
utils.CHECK_EVENT_PERM_FUNC = check_event_perms
utils.CHECK_CALENDAR_PERM_FUNC = check_calendar_perms

Expand All @@ -84,3 +85,6 @@ def test_calendar_and_event_perms(self):

self.client.login(username='bob', password='bob')
self._check_protected_urls(should_allow=False)

utils.CHECK_EVENT_PERM_FUNC = default_event_check
utils.CHECK_CALENDAR_PERM_FUNC = default_cal_check
14 changes: 2 additions & 12 deletions schedule/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
from schedule.views import check_next_url, coerce_date_dict


def check_perms(ob, user):
return user.username == 'ann'


class TestViews(TestCase):
fixtures = ['schedule.json']

Expand Down Expand Up @@ -105,10 +101,7 @@ def test_event_creation_anonymous_user(self):
self.assertEqual(self.response.status_code, 302)

def test_event_creation_authenticated_user(self):
User.objects.create_user(username='ann', password='ann')
utils.CHECK_EVENT_PERM_FUNC = check_perms
utils.CHECK_CALENDAR_PERM_FUNC = check_perms
self.client.login(username="ann", password="ann")
self.client.login(username="admin", password="admin")
self.response = self.client.get(reverse("calendar_create_event",
kwargs={"calendar_slug": 'example'}), {})
print self.response
Expand Down Expand Up @@ -142,10 +135,7 @@ def test_delete_event_anonymous_user(self):
self.assertEqual(self.response.status_code, 302)

def test_delete_event_authenticated_user(self):
User.objects.create_user(username='ann', password='ann')
utils.CHECK_EVENT_PERM_FUNC = check_perms
utils.CHECK_CALENDAR_PERM_FUNC = check_perms
self.client.login(username="ann", password="ann")
self.client.login(username="admin", password="admin")
# Load the deletion page
self.response = self.client.get(reverse("delete_event", kwargs={"event_id": 1}), {})
self.assertEqual(self.response.status_code, 200)
Expand Down

0 comments on commit 58291a6

Please sign in to comment.