# Path: habitat/views/habitat.py
# def validate(new, old, userctx, secobj):


from ...views import habitat
from couch_named_python import ForbiddenError, UnauthorizedError
from nose.tools import assert_raises
#
# habitat is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# habitat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with habitat.  If not, see <http://www.gnu.org/licenses/>.

"""
Tests general habitat views and functions.
"""



def test_only_admins_may_delete():
    assert_raises(UnauthorizedError, habitat.validate,
        {'_deleted': True}, {'whatever': 'whatever'}, {'roles': []}, {})
    habitat.validate(
        {'_deleted': True}, {'whatever': 'whatever'}, {'roles': ['_admin']},
        {})

def test_only_valid_types():
    assert_raises(ForbiddenError, habitat.validate,
        {}, {}, {'roles': []}, {})

# Path: habitat/views/habitat.py
# def validate(new, old, userctx, secobj):


# Path: habitat/tests/test_views/test_habitat.py
from ...views import habitat
from couch_named_python import ForbiddenError, UnauthorizedError
from nose.tools import assert_raises

#
# habitat is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# habitat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with habitat.  If not, see <http://www.gnu.org/licenses/>.

"""
Tests general habitat views and functions.
"""



def test_only_admins_may_delete():
    assert_raises(UnauthorizedError, habitat.validate,
        {'_deleted': True}, {'whatever': 'whatever'}, {'roles': []}, {})
    habitat.validate(
        {'_deleted': True}, {'whatever': 'whatever'}, {'roles': ['_admin']},
        {})

def test_only_valid_types():
    assert_raises(ForbiddenError, habitat.validate,
        {}, {}, {'roles': []}, {})

    assert_raises(ForbiddenError, habitat.validate,