def test_toggle_del(app, setup, zope_auth, client):
    create_user('testuser')
    set_user('testuser')
    initial_value = get_instance(WikiComment, id=1).deleted or 0
    client.get('/species/summary/datasheet/manage_comment/', {
        'comment_id': 1, 'toggle': 'del', 'period': '1'})
    assert get_instance(WikiComment, id=1).deleted == 1 - initial_value
def test_404_error(app, setup, zope_auth, client, request_type, request_args,
                   post_params):
    create_user('otheruser')
    set_user('otheruser')
    resp = getattr(client, request_type)(*get_request_params(
        request_type, request_args, post_params), expect_errors=True)
    assert resp.status_code == 404
def test_get_revision(app, setup, zope_auth, client):
    create_user('testuser', role_names=['etc'])
    set_user('testuser')

    resp = client.get('/species/summary/datasheet/get_revision/', {
        'revision_id': 1})
    assert (resp.html.text == "The wolf was the world's most widely "
            "distributed mammal.")
def test_edit_comment(app, setup, zope_auth, client):
    create_user('testuser', role_names=['stakeholder'])
    set_user('testuser')
    client.post(*get_request_params(
        'post', ['/species/summary/datasheet/edit_comment/', {
            'period': '1', 'subject': 'Canis lupus', 'region': '',
            'comment_id': 1}], {'comment': 'Test edit comment.'}))
    assert get_instance(WikiComment, id=1).comment == 'Test edit comment.'
def test_hide_adm_etc_username(app, setup, zope_auth, client, roles):
    create_user('testuser', roles, 'Secret Name', 'Test Insitution')
    create_user('otheruser')
    set_user('otheruser')

    resp = client.get('/species/summary/datasheet/', {
        'period': '1', 'subject': 'Canis lupus', 'region': ''})
    assert 'Secret Name' not in resp.html.name
def test_change_active_revision(app, setup, zope_auth, client):
    create_user('otheruser', role_names=['etc'])
    set_user('otheruser')
    client.post(*get_request_params(
        'post', ['/species/summary/datasheet/page_history/', {
            'period': '1', 'subject': 'Canis lupus', 'region': ''}],
        {'revision_id': 3}))
    assert get_instance(WikiChange, id=1).active == 0
    assert get_instance(WikiChange, id=3).active == 1
def test_edit_page(app, setup, zope_auth, client):
    create_user('testuser', role_names=['etc'])
    set_user('testuser')
    client.post(*get_request_params(
        'post', ['/species/summary/datasheet/edit_page/', {
            'period': '1', 'subject': 'Canis lupus', 'region': ''}],
        {'text': 'Test edit page.'}))
    assert get_instance(WikiChange, id=1).active == 0
    assert get_instance(WikiChange, body='Test edit page.').active == 1
Exemple #8
0
def test_get_revision(app, setup, set_auth, client):
    create_user('testuser', role_names=['etc'])
    set_user('testuser')
    force_login(client, 'testuser')

    resp = client.get('/species/summary/datasheet/get_revision/',
                      {'revision_id': 1})
    assert (resp.html.text == "The wolf was the world's most widely "
            "distributed mammal.")
Exemple #9
0
def test_perms_auth_user(app, setup, set_auth, client, request_type,
                         request_args, post_params):
    create_user('otheruser')
    set_user('otheruser')
    resp = getattr(client,
                   request_type)(*get_request_params(request_type,
                                                     request_args,
                                                     post_params),
                                 expect_errors=True)
    assert resp.status_code == 403
Exemple #10
0
def test_toggle_del(app, setup, set_auth, client):
    create_user('testuser')
    set_user('testuser')
    force_login(client, 'testuser')
    initial_value = get_instance(WikiComment, id=1).deleted or 0
    client.get('/species/summary/datasheet/manage_comment/', {
        'comment_id': 1,
        'toggle': 'del',
        'period': '5'
    })
    assert get_instance(WikiComment, id=1).deleted == 1 - initial_value
def test_toggle_read(app, setup, zope_auth, client):
    create_user('otheruser')
    set_user('otheruser')

    def get_value():
        return get_instance(WikiComment, id=1) in get_instance(
            RegisteredUser, id='otheruser').read_comments
    initial_value = get_value()
    client.get('/species/summary/datasheet/manage_comment/', {
        'comment_id': 1, 'toggle': 'read', 'period': '1'})
    assert get_value() is not initial_value
Exemple #12
0
def test_hide_adm_etc_username(app, setup, set_auth, client, roles):
    create_user('testuser', roles, 'Secret Name', 'Test Insitution')
    create_user('otheruser')
    set_user('otheruser')
    force_login(client, 'otheruser')

    resp = client.get('/species/summary/datasheet/', {
        'period': '5',
        'subject': 'Canis lupus',
        'region': ''
    })
    assert 'Secret Name' not in resp.html.name
def test_add_comment(app, setup, zope_auth, client):
    create_user('newuser')
    set_user('newuser')
    request_data = ('post', ['/species/summary/datasheet/add_comment/', {
        'period': '1', 'subject': 'Canis lupus', 'region': ''}],
        {'comment': 'Test add comment.'})
    client.post(*get_request_params(*request_data))
    request_args = request_data[1][1]
    wiki = get_instance(Wiki, dataset_id=request_args['period'],
                        assesment_speciesname=request_args['subject'],
                        region_code=request_args['region'])
    assert request_data[2]['comment'] in [c.comment for c in wiki.comments]
Exemple #14
0
def test_edit_comment(app, setup, set_auth, client):
    create_user('testuser', role_names=['stakeholder'])
    set_user('testuser')
    force_login(client, 'testuser')
    client.post(*get_request_params('post', [
        '/species/summary/datasheet/edit_comment/', {
            'period': '5',
            'subject': 'Canis lupus',
            'region': '',
            'comment_id': 1
        }
    ], {'comment': 'Test edit comment.'}))
    assert get_instance(WikiComment, id=1).comment == 'Test edit comment.'
Exemple #15
0
def test_edit_page(app, setup, set_auth, client):
    create_user('testuser', role_names=['etc'])
    set_user('testuser')
    force_login(client, 'testuser')
    client.post(*get_request_params('post', [
        '/species/summary/datasheet/edit_page/', {
            'period': '5',
            'subject': 'Canis lupus',
            'region': ''
        }
    ], {'text': 'Test edit page.'}))
    assert get_instance(WikiChange, id=1).active == 0
    assert get_instance(WikiChange, body='Test edit page.').active == 1
Exemple #16
0
def test_change_active_revision(app, setup, set_auth, client):
    create_user('otheruser', role_names=['etc'])
    set_user('otheruser')
    force_login(client, 'otheruser')
    client.post(*get_request_params('post', [
        '/species/summary/datasheet/page_history/', {
            'period': '5',
            'subject': 'Canis lupus',
            'region': ''
        }
    ], {'revision_id': 3}))
    assert get_instance(WikiChange, id=1).active == 0
    assert get_instance(WikiChange, id=3).active == 1
Exemple #17
0
def test_toggle_read(app, setup, set_auth, client):
    create_user('otheruser')
    set_user('otheruser')
    force_login(client, 'otheruser')

    def get_value():
        return get_instance(WikiComment,
                            id=1) in get_instance(RegisteredUser,
                                                  id='otheruser').read_comments

    initial_value = get_value()
    client.get('/species/summary/datasheet/manage_comment/', {
        'comment_id': 1,
        'toggle': 'read',
        'period': '5'
    })
    assert get_value() is not initial_value
Exemple #18
0
def test_add_comment(app, setup, set_auth, client):
    create_user('newuser')
    set_user('newuser')
    force_login(client, 'newuser')
    request_data = ('post', [
        '/species/summary/datasheet/add_comment/', {
            'period': '5',
            'subject': 'Canis lupus',
            'region': ''
        }
    ], {
        'comment': 'Test add comment.'
    })
    client.post(*get_request_params(*request_data))
    request_args = request_data[1][1]
    wiki = get_instance(Wiki,
                        dataset_id=request_args['period'],
                        assesment_speciesname=request_args['subject'],
                        region_code=request_args['region'])
    assert request_data[2]['comment'] in [c.comment for c in wiki.comments]
 def set_testing_user():
     set_user('foo', is_ldap_user=True)