fix the tower_user module to update the fields properly

This commit is contained in:
Nikhil Jain
2021-03-11 19:14:50 +05:30
parent e8b2072ea5
commit 80023017a2
2 changed files with 28 additions and 7 deletions

View File

@@ -57,3 +57,24 @@ def test_update_password_on_create(run_module, admin_user, mock_auth_stuff):
assert not result.get('failed', False), result.get('msg', result)
assert not result.get('changed')
@pytest.mark.django_db
def test_update_user(run_module, admin_user, mock_auth_stuff):
    result = run_module('tower_user', dict(
        username='Bob',
        password='pass4word',
        is_system_auditor=True
    ), admin_user)
    assert not result.get('failed', False), result.get('msg', result)
    assert result.get('changed'), result
    update_result =     result = run_module('tower_user', dict(
        username='Bob',
        password='pass4word',
        is_system_auditor=False
    ), admin_user)
    assert update_result.get('changed')
    user = User.objects.get(id=result['id'])
    assert not user.is_system_auditor