2018-04-03 19:30:15 +00:00
|
|
|
import pytest
|
|
|
|
from django import db
|
|
|
|
|
|
|
|
|
|
|
|
def test_cannot_duplicate_actor(factories):
|
2018-06-09 13:36:16 +00:00
|
|
|
actor = factories["federation.Actor"]()
|
2018-04-03 19:30:15 +00:00
|
|
|
|
|
|
|
with pytest.raises(db.IntegrityError):
|
2018-06-09 13:36:16 +00:00
|
|
|
factories["federation.Actor"](
|
|
|
|
domain=actor.domain, preferred_username=actor.preferred_username
|
2018-04-03 19:30:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_cannot_duplicate_follow(factories):
|
2018-06-09 13:36:16 +00:00
|
|
|
follow = factories["federation.Follow"]()
|
2018-04-03 19:30:15 +00:00
|
|
|
|
|
|
|
with pytest.raises(db.IntegrityError):
|
2018-06-09 13:36:16 +00:00
|
|
|
factories["federation.Follow"](target=follow.target, actor=follow.actor)
|
2018-04-03 21:25:44 +00:00
|
|
|
|
2018-04-06 16:49:29 +00:00
|
|
|
|
2018-04-03 21:25:44 +00:00
|
|
|
def test_follow_federation_url(factories):
|
2018-06-09 13:36:16 +00:00
|
|
|
follow = factories["federation.Follow"](local=True)
|
|
|
|
expected = "{}#follows/{}".format(follow.actor.url, follow.uuid)
|
2018-04-03 21:25:44 +00:00
|
|
|
|
|
|
|
assert follow.get_federation_url() == expected
|
2018-04-04 21:12:41 +00:00
|
|
|
|
|
|
|
|
2018-04-06 16:49:29 +00:00
|
|
|
def test_library_model_unique_per_actor(factories):
|
2018-06-09 13:36:16 +00:00
|
|
|
library = factories["federation.Library"]()
|
2018-04-06 16:49:29 +00:00
|
|
|
with pytest.raises(db.IntegrityError):
|
2018-06-09 13:36:16 +00:00
|
|
|
factories["federation.Library"](actor=library.actor)
|