Example #1
0
def test_set_hidden_yes_no_change(capsys):
    user_id = users.create_user("username", "*****@*****.**", users.UserType.PERSON).id
    user = users.get_user(user_id)
    user.is_hidden = True
    db.session.add(user)
    db.session.commit()

    scripts.main([scripts.__file__, 'set_user_hidden', str(user_id), 'yes'])
    assert 'Success' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert user.is_hidden
Example #2
0
def test_set_administrator_no(capsys):
    user_id = users.create_user("username", "*****@*****.**", users.UserType.PERSON).id
    user = users.get_user(user_id)
    user.is_admin = True
    db.session.add(user)
    db.session.commit()

    scripts.main([scripts.__file__, 'set_administrator', str(user_id), 'no'])
    assert 'Success' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert not user.is_admin
def test_set_readonly_no(capsys):
    user_id = users.create_user("username", "*****@*****.**",
                                users.UserType.PERSON).id
    user = users.get_user(user_id)
    user.is_readonly = True
    db.session.add(user)
    db.session.commit()

    scripts.main([scripts.__file__, 'set_user_readonly', str(user_id), 'no'])
    assert 'Success' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert not user.is_readonly
Example #4
0
def test_set_hidden_no_no_change(capsys):
    user_id = users.create_user("username", "*****@*****.**", users.UserType.PERSON).id

    scripts.main([scripts.__file__, 'set_user_hidden', str(user_id), 'no'])
    assert 'Success' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert not user.is_hidden
Example #5
0
def test_set_hidden_yes(capsys):
    user_id = users.create_user("username", "*****@*****.**", users.UserType.PERSON).id

    scripts.main([scripts.__file__, 'set_user_hidden', str(user_id), 'yes'])
    assert 'Success' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert user.is_hidden
Example #6
0
def test_set_administrator_no_no_change(capsys):
    user_id = users.create_user("username", "*****@*****.**", users.UserType.PERSON).id

    scripts.main([scripts.__file__, 'set_administrator', str(user_id), 'no'])
    assert 'Success' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert not user.is_admin
def test_set_readonly_yes(capsys):
    user_id = users.create_user("username", "*****@*****.**",
                                users.UserType.PERSON).id

    scripts.main([scripts.__file__, 'set_user_readonly', str(user_id), 'yes'])
    assert 'Success' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert user.is_readonly
Example #8
0
def test_set_hidden_invalid_argument(capsys):
    user_id = users.create_user("username", "*****@*****.**", users.UserType.PERSON).id

    with pytest.raises(SystemExit) as exc_info:
        scripts.main([scripts.__file__, 'set_user_hidden', str(user_id), 'maybe'])
    assert exc_info.value != 0
    assert 'Usage' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert not user.is_hidden
Example #9
0
def test_set_administrator_missing_arguments(capsys):
    user_id = users.create_user("username", "*****@*****.**", users.UserType.PERSON).id

    with pytest.raises(SystemExit) as exc_info:
        scripts.main([scripts.__file__, 'set_administrator', str(user_id)])
    assert exc_info.value != 0
    assert 'Usage' in capsys.readouterr()[0]
    user = users.get_user(user_id)
    assert not user.is_admin