Changeset 78af3d1 in OpenWorkouts-current for ow/tests/models/test_workout.py


Ignore:
Timestamp:
Feb 9, 2019, 9:42:52 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
56caf3d
Parents:
55470f9
Message:

Fix permissions. From now on users can see (and edit, delete, etc) their own data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/tests/models/test_workout.py

    r55470f9 r78af3d1  
    66
    77import pytest
    8 from pyramid.security import Allow, Everyone
     8from pyramid.security import Allow, Everyone, Deny, ALL_PERMISSIONS
    99
    1010from ow.models.workout import Workout
     
    3333    def test__acl__(self, root):
    3434        # First check permissions for a workout without parent
    35         permissions = [(Allow, Everyone, 'view'),
    36                        (Allow, 'group:admins', 'edit')]
    37         workout = Workout()
    38         assert workout.__acl__() == permissions
    39 
     35        workout = Workout()
     36        with pytest.raises(AttributeError):
     37            workout.__acl__()
    4038        # Now permissions on a workout that has been added to a user
    4139        uid = str(root['john'].uid)
    42         permissions = [(Allow, uid, 'view'), (Allow, uid, 'edit')]
    43         assert root['john']['1'].__acl__() == permissions
     40        workout = root['john']['1']
     41        permissions = [
     42            (Allow, uid, 'view'),
     43            (Allow, uid, 'edit'),
     44            (Allow, uid, 'delete'),
     45            (Deny, Everyone, ALL_PERMISSIONS)
     46        ]
     47        assert workout.__acl__() == permissions
    4448
    4549    def test_runthrough(self, root):
Note: See TracChangeset for help on using the changeset viewer.