Skip to content
Snippets Groups Projects
Select Git revision
  • develop default protected
  • master
  • in-place-import-wont-change-library-quota
  • embed
  • user-collections
  • live-streaming
  • eliotberriot-develop-patch-30242
  • build-docker-unprivileged
  • 463-user-libraries
  • avatar-everywhere
  • playlist-component
  • 303-json-ld
  • 334-don-t-display-an-empty-page-browser
  • 316-ultrasonic
  • ButterflyOfFire/funkwhale-patch-1
  • 278-search-browse
  • 0.17
  • 0.16.3
  • 0.16.2
  • 0.16.1
  • 0.16
  • 0.15
  • 0.14.2
  • 0.14.1
  • 0.14
  • 0.13
  • 0.12
  • 0.11
  • 0.10
  • 0.9.1
  • 0.9
  • 0.8
  • 0.7
  • 0.6.1
  • 0.6
  • 0.5.4
36 results

test_models.py

Blame
  • Forked from funkwhale / funkwhale
    6309 commits behind, 2 commits ahead of the upstream repository.
    test_models.py 1.77 KiB
    import pytest
    from django import db
    
    
    def test_cannot_duplicate_actor(factories):
        actor = factories["federation.Actor"]()
    
        with pytest.raises(db.IntegrityError):
            factories["federation.Actor"](
                domain=actor.domain, preferred_username=actor.preferred_username
            )
    
    
    def test_cannot_duplicate_follow(factories):
        follow = factories["federation.Follow"]()
    
        with pytest.raises(db.IntegrityError):
            factories["federation.Follow"](target=follow.target, actor=follow.actor)
    
    
    def test_follow_federation_url(factories):
        follow = factories["federation.Follow"](local=True)
        expected = "{}#follows/{}".format(follow.actor.fid, follow.uuid)
    
        assert follow.get_federation_id() == expected
    
    
    def test_actor_get_quota(factories):
        library = factories["music.Library"]()
        factories["music.Upload"](
            library=library,
            import_status="pending",
            audio_file__from_path=None,
            audio_file__data=b"a",
        )
        factories["music.Upload"](
            library=library,
            import_status="skipped",
            audio_file__from_path=None,
            audio_file__data=b"aa",
        )
        factories["music.Upload"](
            library=library,
            import_status="errored",
            audio_file__from_path=None,
            audio_file__data=b"aaa",
        )
        factories["music.Upload"](
            library=library,
            import_status="finished",
            audio_file__from_path=None,
            audio_file__data=b"aaaa",
        )
        factories["music.Upload"](
            library=library,
            import_status="finished",
            audio_file__from_source="files:///path/to/mytrack.mp3",
            audio_file__data=b"aaaaa",
        )
        expected = {"total": 10, "pending": 1, "skipped": 2, "errored": 3, "finished": 4}
    
        assert library.actor.get_current_usage() == expected