def test_get_model_permissions(): """ We can create the correct model permissions from user permissions """ user = UserFactory(permissions=("books.view_book", "books.view_author")) assert get_view_permissions(user) == {"books.book", "books.author"} # test for camel cased app names user = MagicMock() user.get_all_permissions = Mock( return_value={"BookShelf.view_author", "BookShelf.view_book"}) assert get_view_permissions(user) == {"BookShelf.book", "BookShelf.author"}
def test_get_model_permissions(): """ We can create the correct model permissions from user permissions """ user = UserFactory(permissions=("books.view_book", "books.view_author")) assert get_view_permissions(user) == {"books.book", "books.author"}
def test_get_model_permissions_lowercased(): """ When our permissions are upper cased (we had an app with an upper case letter) we still get user perms in lower case """ user = UserFactory(permissions=("books.view_book", "books.view_author")) user.user_permissions.update(codename=Upper("codename")) assert get_view_permissions(user) == {"books.book", "books.author"}
def test_get_model_permissions(): """ We can create the correct model permissions from user permissions """ user = user_with_permissions('polls.view_poll', 'polls.view_choice') assert get_view_permissions(user) == {'polls.poll', 'polls.choice'}
def test_get_model_permissions_lowercased(): """ When our permissions are upper cased (we had an app with an upper case letter) we still get user perms in lower case """ user = user_with_permissions("polls.view_poll", "polls.view_choice") user.user_permissions.update(codename=Upper("codename")) assert get_view_permissions(user) == {"polls.poll", "polls.choice"}