Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from django.core.management import call_command
from funkwhale_api.federation import models as federation_models
from funkwhale_api.federation.management.commands import fix_federation_ids
from funkwhale_api.music import models as music_models
def test_fix_fids_dry_run(factories, mocker):
replace_prefix = mocker.patch("funkwhale_api.common.utils.replace_prefix")
call_command("fix_federation_ids", "http://old/", "https://new/", interactive=False)
replace_prefix.assert_not_called()
def test_fix_fids_no_dry_run(factories, mocker, queryset_equal_queries):
replace_prefix = mocker.patch("funkwhale_api.common.utils.replace_prefix")
factories["federation.Actor"](fid="http://old/test")
call_command(
"fix_federation_ids",
"http://old",
"https://new",
interactive=False,
dry_run=False,
)
models = [
(music_models.Artist, ["fid"]),
(music_models.Album, ["fid"]),
(music_models.Track, ["fid"]),
(music_models.Upload, ["fid"]),
(music_models.Library, ["fid", "followers_url"]),
(
federation_models.Actor,
[
"fid",
"url",
"outbox_url",
"inbox_url",
"following_url",
"followers_url",
"shared_inbox_url",
],
),
(federation_models.Activity, ["fid"]),
(federation_models.Follow, ["fid"]),
(federation_models.LibraryFollow, ["fid"]),
]
assert models == fix_federation_ids.MODELS
for kls, fields in models:
for field in fields:
replace_prefix.assert_any_call(
kls.objects.all(), field, old="http://old", new="https://new"
)