mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-11-03 18:53:17 -05:00 
			
		
		
		
	* fix: failed tests when env default email/password changed * Remove default email exposition in docs
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from pytest import fixture
 | 
						|
from starlette.testclient import TestClient
 | 
						|
 | 
						|
from mealie.core.config import get_app_settings
 | 
						|
from tests import utils
 | 
						|
 | 
						|
 | 
						|
@fixture(scope="session")
 | 
						|
def admin_token(api_client: TestClient, api_routes: utils.AppRoutes):
 | 
						|
    settings = get_app_settings()
 | 
						|
 | 
						|
    form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
 | 
						|
    return utils.login(form_data, api_client, api_routes)
 | 
						|
 | 
						|
 | 
						|
@fixture(scope="session")
 | 
						|
def admin_user(api_client: TestClient, api_routes: utils.AppRoutes):
 | 
						|
    settings = get_app_settings()
 | 
						|
 | 
						|
    form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
 | 
						|
 | 
						|
    token = utils.login(form_data, api_client, api_routes)
 | 
						|
 | 
						|
    user_data = api_client.get(api_routes.users_self, headers=token).json()
 | 
						|
    assert token is not None
 | 
						|
 | 
						|
    assert user_data.get("admin") is True
 | 
						|
    assert user_data.get("groupId") is not None
 | 
						|
    assert user_data.get("id") is not None
 | 
						|
 | 
						|
    try:
 | 
						|
        yield utils.TestUser(
 | 
						|
            _group_id=user_data.get("groupId"),
 | 
						|
            user_id=user_data.get("id"),
 | 
						|
            username=user_data.get("username"),
 | 
						|
            email=user_data.get("email"),
 | 
						|
            token=token,
 | 
						|
        )
 | 
						|
    finally:
 | 
						|
        # TODO: Delete User after test
 | 
						|
        pass
 |