예제 #1
0
    def test_delete_redirects_to_org_list(self, matchers, org, pyramid_request):
        ctrl = OrganizationEditController(org, pyramid_request)

        response = ctrl.delete()

        list_url = pyramid_request.route_path('admin_organizations')
        assert response == matchers.Redirect302To(list_url)
예제 #2
0
    def test_delete_redirects_to_org_list(self, org, pyramid_request):
        ctrl = OrganizationEditController(org, pyramid_request)

        response = ctrl.delete()

        list_url = pyramid_request.route_path('admin_organizations')
        assert response == redirect_302_to(list_url)
예제 #3
0
    def test_delete_fails_if_org_has_groups(self, factories, matchers, org, pyramid_request):
        factories.Group(name='Test', organization=org)
        ctrl = OrganizationEditController(org, pyramid_request)

        ctx = ctrl.delete()

        assert org not in pyramid_request.db.deleted
        assert pyramid_request.response.status_int == 400
        pyramid_request.session.flash.assert_called_with(
            matchers.Regex('.*Cannot delete.*1 groups'), 'error')
        assert ctx['form'] == self._expected_form(org)
예제 #4
0
    def test_delete_fails_if_org_has_groups(self, factories, matchers, org,
                                            pyramid_request):
        factories.Group(name='Test', organization=org)
        ctrl = OrganizationEditController(org, pyramid_request)

        ctx = ctrl.delete()

        assert org not in pyramid_request.db.deleted
        assert pyramid_request.response.status_int == 400
        pyramid_request.session.flash.assert_called_with(
            matchers.Regex('.*Cannot delete.*1 groups'), 'error')
        assert ctx['form'] == self._expected_form(org)
예제 #5
0
 def test_delete_removes_org(self, pyramid_request, db_session, org):
     ctrl = OrganizationEditController(org, pyramid_request)
     ctrl.delete()
     assert org in db_session.deleted
예제 #6
0
 def test_delete_removes_org(self, pyramid_request, db_session, org):
     ctrl = OrganizationEditController(org, pyramid_request)
     ctrl.delete()
     assert org in db_session.deleted