mirror of
				https://github.com/fastapi-users/fastapi-users.git
				synced 2025-11-01 01:48:46 +08:00 
			
		
		
		
	Add unit test to check email validation
This commit is contained in:
		| @ -26,8 +26,8 @@ class User(models.BaseUser): | |||||||
|     first_name: Optional[str] |     first_name: Optional[str] | ||||||
|  |  | ||||||
|  |  | ||||||
| class UserCreate(User, models.BaseUserCreate): | class UserCreate(models.BaseUserCreate): | ||||||
|     pass |     first_name: Optional[str] | ||||||
|  |  | ||||||
|  |  | ||||||
| class UserUpdate(User, models.BaseUserUpdate): | class UserUpdate(User, models.BaseUserUpdate): | ||||||
|  | |||||||
| @ -49,6 +49,14 @@ class TestRegister: | |||||||
|         assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY |         assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY | ||||||
|         assert after_register.called is False |         assert after_register.called is False | ||||||
|  |  | ||||||
|  |     async def test_missing_email( | ||||||
|  |         self, test_app_client: httpx.AsyncClient, after_register | ||||||
|  |     ): | ||||||
|  |         json = {"password": "guinevere"} | ||||||
|  |         response = await test_app_client.post("/register", json=json) | ||||||
|  |         assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY | ||||||
|  |         assert after_register.called is False | ||||||
|  |  | ||||||
|     async def test_missing_password( |     async def test_missing_password( | ||||||
|         self, test_app_client: httpx.AsyncClient, after_register |         self, test_app_client: httpx.AsyncClient, after_register | ||||||
|     ): |     ): | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 François Voron
					François Voron