def test_correct_setters():
    account_main = AccountMain()

    account_session = AccountSession()
    account_session.account_main = account_main

    assert account_session.account_main is account_main
    async def auth_basic(account_main: AccountMain) -> Tuple[Optional[AccountMain], Optional[Error]]:
        account_main.create_hash_password()
        account_main, err = await AccountMainDao().get_by_email_hash_password(account_main)
        if err:
            return None, err

        if not account_main:
            return None, ErrorEnum.WRONG_EMAIL_PASSWORD

        account_session = AccountSession(account_main=account_main)
        account_session, err = await AccountSessionDao().add(account_session)
        if err:
            return None, err

        account_main.auth_token = account_session.create_token()

        return account_main, None
    async def register(account_main: AccountMain) -> Tuple[Optional[AccountMain], Optional[Error]]:
        account_main.create_hash_password()
        account_main, err = await AccountMainDao().add(account_main)
        if err:
            return None, err

        account_session = AccountSession(account_main=account_main)
        account_session, err = await AccountSessionDao().add(account_session)
        if err:
            return None, err

        account_main.auth_token = account_session.create_token()

        auth_code = AuthCode(account_main=account_main)
        auth_code.create_random_code()

        _, err = await AuthCodeDao().add(auth_code)

        account_main.is_email_sent = Mail.send_email(EMAIL_CODE_TYPE, account_main.email, auth_code.code)

        return account_main, None
def test_empty_init():
    account_session = AccountSession()

    assert account_session.account_main is None
def test_incorrect_setters():
    account_session = AccountSession()

    with pytest.raises(TypeError):
        account_session.account_main = 1234
def test_incorrect_init():
    with pytest.raises(TypeError):
        AccountSession(account_main=123)
def test_correct_init():
    account_main = AccountMain()

    account_session = AccountSession(account_main=account_main)
    assert account_session.account_main is account_main