Fix account access edge cases
Commit 745a8 pushed by Anže Pečar

57 tests 49 passed 8 failed Duration
self = <accounts.tests.TestSelectedInstance testMethod=test_invalid_selected_instance>

    def test_invalid_selected_instance(self):
>       response = self.client.get("/?selected_instance=invalid")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

accounts/tests.py:162: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb40778da90>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb40778da90>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError
Stdout
Done 🎉
self = <accounts.tests.TestSelectedInstance testMethod=test_no_selected_instance>

    def test_no_selected_instance(self):
>       response = self.client.get("/")
                   ^^^^^^^^^^^^^^^^^^^^

accounts/tests.py:72: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb4072cfed0>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb4072cfed0>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError
self = <accounts.tests.TestSelectedInstance testMethod=test_selected_instance>

    def test_selected_instance(self):
>       response = self.client.get("/?selected_instance=mastodon.social")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

accounts/tests.py:86: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb4072cf110>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb4072cf110>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError
self = <accounts.tests.TestSelectedInstance testMethod=test_selected_instance_https_truncate>

    def test_selected_instance_https_truncate(self):
>       response = self.client.get("/?selected_instance=https://mastodon.social")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

accounts/tests.py:117: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb407445220>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb407445220>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError
self = <accounts.tests.TestSelectedInstance testMethod=test_selected_instance_http_truncate>

    def test_selected_instance_http_truncate(self):
>       response = self.client.get("/?selected_instance=https://mastodon.social")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

accounts/tests.py:132: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb407445e00>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb407445e00>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError
self = <accounts.tests.TestSelectedInstance testMethod=test_selected_instance_slash_truncate>

    def test_selected_instance_slash_truncate(self):
>       response = self.client.get("/?selected_instance=https://mastodon.social/")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

accounts/tests.py:147: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb4077929f0>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb4077929f0>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError
self = <accounts.tests.TestSelectedInstance testMethod=test_selected_instance_through_session>

    def test_selected_instance_through_session(self):
>       self.client.get("/?selected_instance=mastodon.social")

accounts/tests.py:176: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb4065f3350>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb4065f3350>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError
self = <accounts.tests.TestSelectedInstance testMethod=test_unselected_instance>

    def test_unselected_instance(self):
>       self.client.get("/?selected_instance=mastodon.social")

accounts/tests.py:101: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.13/site-packages/django/test/client.py:1124: in get
    response = super().get(
.venv/lib/python3.13/site-packages/django/test/client.py:475: in get
    return self.generic(
.venv/lib/python3.13/site-packages/django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/test/client.py:1087: in request
    self.check_exception(response)
.venv/lib/python3.13/site-packages/django/test/client.py:802: in check_exception
    raise exc_value
.venv/lib/python3.13/site-packages/django/core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
accounts/views.py:281: in index
    account_access = request.user.accountaccess.account
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fb4065f0270>>
args = ('accountaccess',)
_wrapped = <django.contrib.auth.models.AnonymousUser object at 0x7fb4065f0270>

    def inner(self, *args):
        if (_wrapped := self._wrapped) is empty:
            self._setup()
            _wrapped = self._wrapped
>       return func(_wrapped, *args)
               ^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: 'AnonymousUser' object has no attribute 'accountaccess'

.venv/lib/python3.13/site-packages/django/utils/functional.py:253: AttributeError