コード例 #1
0
    def test_has_object_permission_has_permission(self, mock_has_permission):
        mock_has_permission.return_value = True

        result = has_object_permission(self.product_type, 'Product_Type_View')

        self.assertTrue(result)
        mock_has_permission.assert_called_with(None, self.product_type,
                                               Permissions.Product_Type_View)
コード例 #2
0
    def test_has_object_permission_has_permission(self, mock_current_user,
                                                  mock_has_permission):
        mock_has_permission.return_value = True
        mock_current_user.return_value = self.user

        result = has_object_permission(self.product_type, 'Product_Type_View')

        self.assertTrue(result)
        mock_has_permission.assert_called_with(self.user, self.product_type,
                                               Permissions.Product_Type_View)
        mock_current_user.assert_called_once()
コード例 #3
0
    def test_has_object_permission_wrong_permission(self):

        with self.assertRaises(KeyError):
            result = has_object_permission(self.product_type, 'Test')
コード例 #4
0
    def test_has_object_permission_legacy(self):

        result = has_object_permission(self.product_type,
                                       Permissions.Product_Type_View)

        self.assertFalse(result)