diff --git a/web_app/tests/test_create_referal_link.py b/web_app/tests/test_create_referal_link.py index 9d42fb5f4..587215288 100644 --- a/web_app/tests/test_create_referal_link.py +++ b/web_app/tests/test_create_referal_link.py @@ -24,36 +24,18 @@ def client(): with TestClient(app) as client: yield client - -@pytest.mark.asyncio -async def test_create_referal_link_success(client): - """Test successful referral link creation with a valid wallet ID.""" - with patch("web_app.db.database.get_database") as mock_get_db: # Changed here - mock_db = MagicMock() - mock_get_db.return_value = mock_db - mock_user = MagicMock(spec=User) - mock_user.wallet_id = "wallet123" - mock_db.query().filter().first.return_value = mock_user - response = client.get("/api/create_referal_link?wallet_id=wallet123") - assert response.status_code == 200 - data = response.json() - assert data["wallet_id"] == "wallet123" - assert len(data["referral_code"]) == 16 - - @pytest.mark.asyncio async def test_create_referal_link_missing_wallet_id(client): """Test error when wallet ID is missing in the request.""" response = client.get("/api/create_referal_link") assert response.status_code == 422 data = response.json() - assert data["detail"][0]["msg"] == "Field required" # Updated here - + assert data["detail"][0]["msg"] == "Field required" @pytest.mark.asyncio async def test_create_referal_link_user_not_found(client): """Test error when the user is not found in the database.""" - with patch("web_app.db.database.get_database") as mock_get_db: # Changed here + with patch("web_app.db.database.get_database") as mock_get_db: mock_db = MagicMock() mock_get_db.return_value = mock_db mock_db.query().filter().first.return_value = None