def test_save_category_fails_if_integrity_error(self): """Test save_category raises a DBIntegrityError if the instance to be saved lacks a required value""" category = CategoryFactory.build(name=None) assert_raises(DBIntegrityError, self.project_repo.save_category, category)
def test_admin_can_crud(self): """Test admin user can crud categories""" category = CategoryFactory.build() assert_not_raises(Forbidden, ensure_authorized_to, 'create', category) assert_not_raises(Forbidden, ensure_authorized_to, 'read', category) assert_not_raises(Forbidden, ensure_authorized_to, 'read', Category) assert_not_raises(Forbidden, ensure_authorized_to, 'update', category) assert_not_raises(Forbidden, ensure_authorized_to, 'delete', category)
def test_authenticated_user_can_crud(self): """Test authenticated users cannot crud categories""" category = CategoryFactory.build() assert_raises(Forbidden, ensure_authorized_to, 'create', category) assert_not_raises(Exception, ensure_authorized_to, 'read', category) assert_not_raises(Exception, ensure_authorized_to, 'read', Category) assert_raises(Forbidden, ensure_authorized_to, 'update', category) assert_raises(Forbidden, ensure_authorized_to, 'delete', category)
def test_anonymous_user_cannot_crud(self): """Test anonymous users cannot crud categories""" category = CategoryFactory.build() assert_raises(Unauthorized, ensure_authorized_to, 'create', category) assert_not_raises(Exception, ensure_authorized_to, 'read', category) assert_not_raises(Exception, ensure_authorized_to, 'read', Category) assert_raises(Unauthorized, ensure_authorized_to, 'update', category) assert_raises(Unauthorized, ensure_authorized_to, 'delete', category)
def test_admin_can_crud(self): """Test admin user can crud categories""" category = CategoryFactory.build() assert_not_raises(Forbidden, ensure_authorized_to, "create", category) assert_not_raises(Forbidden, ensure_authorized_to, "read", category) assert_not_raises(Forbidden, ensure_authorized_to, "read", Category) assert_not_raises(Forbidden, ensure_authorized_to, "update", category) assert_not_raises(Forbidden, ensure_authorized_to, "delete", category)
def test_authenticated_user_can_crud(self): """Test authenticated users cannot crud categories""" category = CategoryFactory.build() assert_raises(Forbidden, ensure_authorized_to, "create", category) assert_not_raises(Exception, ensure_authorized_to, "read", category) assert_not_raises(Exception, ensure_authorized_to, "read", Category) assert_raises(Forbidden, ensure_authorized_to, "update", category) assert_raises(Forbidden, ensure_authorized_to, "delete", category)
def test_anonymous_user_cannot_crud(self): """Test anonymous users cannot crud categories""" category = CategoryFactory.build() assert_raises(Unauthorized, ensure_authorized_to, "create", category) assert_not_raises(Exception, ensure_authorized_to, "read", category) assert_not_raises(Exception, ensure_authorized_to, "read", Category) assert_raises(Unauthorized, ensure_authorized_to, "update", category) assert_raises(Unauthorized, ensure_authorized_to, "delete", category)
def test_save_category(self): """Test save_category persist the category""" category = CategoryFactory.build() assert self.project_repo.get(category.id) is None self.project_repo.save_category(category) assert self.project_repo.get_category(category.id) == category, "Category not saved"
def test_default_index(self): """Tests default index for Category instances""" c = CategoryFactory.build(name="drought risk") self.assertEquals(c.index, 1000)