Skip to content
Snippets Groups Projects
test_models.py 942 B
Newer Older
  • Learn to ignore specific revisions
  • import pytest
    from django import db
    
    
    def test_cannot_duplicate_actor(factories):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        actor = factories["federation.Actor"]()
    
    
        with pytest.raises(db.IntegrityError):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
            factories["federation.Actor"](
                domain=actor.domain, preferred_username=actor.preferred_username
    
            )
    
    
    def test_cannot_duplicate_follow(factories):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        follow = factories["federation.Follow"]()
    
    
        with pytest.raises(db.IntegrityError):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
            factories["federation.Follow"](target=follow.target, actor=follow.actor)
    
    def test_follow_federation_url(factories):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        follow = factories["federation.Follow"](local=True)
        expected = "{}#follows/{}".format(follow.actor.url, follow.uuid)
    
    
        assert follow.get_federation_url() == expected
    
    def test_library_model_unique_per_actor(factories):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        library = factories["federation.Library"]()
    
        with pytest.raises(db.IntegrityError):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
            factories["federation.Library"](actor=library.actor)