nebius/SWE-bench-extra huggingface dataset:
Repository: jupyterhub/nativeauthenticator

Issue:
Make delete_user method delete UserInfo as well
As explained on #44 we should overwrite the `delete_user` method to delete a User on UserInfo table as well.

Comments:

Patch:
diff --git a/nativeauthenticator/nativeauthenticator.py b/nativeauthenticator/nativeauthenticator.py
index f0e7207..2cff990 100644
--- a/nativeauthenticator/nativeauthenticator.py
+++ b/nativeauthenticator/nativeauthenticator.py
@@ -2,6 +2,7 @@ import bcrypt
 import os
 from datetime import datetime
 from jupyterhub.auth import Authenticator
+from jupyterhub.orm import User
 
 from sqlalchemy import inspect
 from tornado import gen
@@ -149,7 +150,11 @@ class NativeAuthenticator(Authenticator):
             infos.update({'is_authorized': True})
 
         user_info = UserInfo(**infos)
-        self.db.add(user_info)
+        user = User(name=username)
+
+        self.db.add_all([user_info, user])
+        self.db.commit()
+
         return user_info
 
     def change_password(self, username, new_password):
@@ -171,3 +176,9 @@ class NativeAuthenticator(Authenticator):
             (r'/change-password', ChangePasswordHandler),
         ]
         return super().get_handlers(app) + native_handlers
+
+    def delete_user(self, user):
+        user_info = UserInfo.find(self.db, user.name)
+        self.db.delete(user_info)
+        self.db.commit()
+        return super().delete_user(user)


Test patch:
diff --git a/nativeauthenticator/tests/test_authenticator.py b/nativeauthenticator/tests/test_authenticator.py
index c5f55ce..5475409 100644
--- a/nativeauthenticator/tests/test_authenticator.py
+++ b/nativeauthenticator/tests/test_authenticator.py
@@ -1,5 +1,6 @@
 import pytest
 import time
+from jupyterhub.orm import User
 from jupyterhub.tests.mocking import MockHub
 
 from nativeauthenticator import NativeAuthenticator
@@ -40,9 +41,11 @@ async def test_create_user(is_admin, open_signup, expected_authorization,
         auth.open_signup = True
 
     auth.get_or_create_user('johnsnow', 'password')
-    user = UserInfo.find(app.db, 'johnsnow')
-    assert user.username == 'johnsnow'
-    assert user.is_authorized == expected_authorization
+    user_info = UserInfo.find(app.db, 'johnsnow')
+    user = User.find(app.db, 'johnsnow')
+    assert user_info.username == 'johnsnow'
+    assert user.name == 'johnsnow'
+    assert user_info.is_authorized == expected_authorization
 
 
 async def test_create_user_bas_characters(tmpcwd, app):
@@ -154,3 +157,14 @@ async def test_change_password(tmpcwd, app):
     auth.change_password('johnsnow', 'newpassword')
     assert not user.is_valid_password('password')
     assert user.is_valid_password('newpassword')
+
+
+async def test_delete_user(tmpcwd, app):
+    auth = NativeAuthenticator(db=app.db)
+    auth.get_or_create_user('johnsnow', 'password')
+
+    user = User.find(app.db, 'johnsnow')
+    auth.delete_user(user)
+
+    user_info = UserInfo.find(app.db, 'johnsnow')
+    assert not user_info