system_conf property on Actor instances
This commit is contained in:
parent
a81c92dbf5
commit
168c4e7d53
|
@ -65,3 +65,9 @@ class Actor(models.Model):
|
||||||
settings.FEDERATION_HOSTNAME == self.domain,
|
settings.FEDERATION_HOSTNAME == self.domain,
|
||||||
self.preferred_username in actors.SYSTEM_ACTORS
|
self.preferred_username in actors.SYSTEM_ACTORS
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def system_conf(self):
|
||||||
|
from . import actors
|
||||||
|
if self.is_system:
|
||||||
|
return actors.SYSTEM_ACTORS[self.preferred_username]
|
||||||
|
|
|
@ -216,6 +216,22 @@ def test_actor_is_system(
|
||||||
assert actor.is_system is expected
|
assert actor.is_system is expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('username,domain,expected', [
|
||||||
|
('test', 'wrongdomain.com', None),
|
||||||
|
('notsystem', '', None),
|
||||||
|
('test', '', actors.SYSTEM_ACTORS['test']),
|
||||||
|
])
|
||||||
|
def test_actor_is_system(
|
||||||
|
username, domain, expected, nodb_factories, settings):
|
||||||
|
if not domain:
|
||||||
|
domain = settings.FEDERATION_HOSTNAME
|
||||||
|
actor = nodb_factories['federation.Actor'](
|
||||||
|
preferred_username=username,
|
||||||
|
domain=domain,
|
||||||
|
)
|
||||||
|
assert actor.system_conf == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('value', [False, True])
|
@pytest.mark.parametrize('value', [False, True])
|
||||||
def test_library_actor_manually_approves_based_on_setting(
|
def test_library_actor_manually_approves_based_on_setting(
|
||||||
value, settings):
|
value, settings):
|
||||||
|
|
Loading…
Reference in New Issue