Пример #1
0
def test_notifications_with_invalid_data_returns_form():
    request = DummyRequest(post={})
    controller = NotificationsController(request)
    controller.form = invalid_form()

    result = controller.notifications()

    assert 'form' in result
Пример #2
0
def test_notifications_with_invalid_data_returns_form():
    request = DummyRequest(post={})
    controller = NotificationsController(request)
    controller.form = invalid_form()

    result = controller.notifications()

    assert 'form' in result
Пример #3
0
def test_notifications_form_with_valid_data_updates_subscriptions(authn_policy,
                                                                  subscriptions_model):
    request = DummyRequest(post={})
    authn_policy.authenticated_userid.return_value = 'fiona'
    subs = [
        FakeSubscription('reply', True),
        FakeSubscription('foo', False),
    ]
    subscriptions_model.get_subscriptions_for_uri.return_value = subs
    controller = NotificationsController(request)
    controller.form = form_validating_to({
        'notifications': set(['foo'])
    })

    controller.notifications()

    assert subs[0].active == False
    assert subs[1].active == True
Пример #4
0
def test_notifications_form_with_valid_data_updates_subscriptions(authn_policy,
                                                                  subscriptions_model):
    request = DummyRequest(post={})
    authn_policy.authenticated_userid.return_value = 'fiona'
    subs = [
        FakeSubscription('reply', True),
        FakeSubscription('foo', False),
    ]
    subscriptions_model.get_subscriptions_for_uri.return_value = subs
    controller = NotificationsController(request)
    controller.form = form_validating_to({
        'notifications': set(['foo'])
    })

    controller.notifications()

    assert subs[0].active == False
    assert subs[1].active == True
Пример #5
0
def test_notifications_with_invalid_data_returns_form(authn_policy):
    request = DummyRequest(post={})
    authn_policy.authenticated_userid.return_value = 'jerry'
    controller = NotificationsController(request)
    controller.form = invalid_form()

    result = controller.notifications()

    assert 'form' in result
Пример #6
0
def test_notifications_form_with_valid_data_redirects(authn_policy,
                                                      subscriptions_model):
    request = DummyRequest(post={})
    authn_policy.authenticated_userid.return_value = 'fiona'
    subscriptions_model.get_subscriptions_for_uri.return_value = []
    controller = NotificationsController(request)
    controller.form = form_validating_to({})

    result = controller.notifications()

    assert isinstance(result, httpexceptions.HTTPFound)
Пример #7
0
def test_notifications_form_with_valid_data_redirects(authn_policy,
                                                      subscriptions_model):
    request = DummyRequest(post={})
    authn_policy.authenticated_userid.return_value = 'fiona'
    subscriptions_model.get_subscriptions_for_uri.return_value = []
    controller = NotificationsController(request)
    controller.form = form_validating_to({})

    result = controller.notifications()

    assert isinstance(result, httpexceptions.HTTPFound)