factories.py 1.26 KB
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
import random

from mopidy import models

import factory


class ArtistJSONFactory(factory.Factory):
    id = factory.Sequence(int)
    mbid = factory.Faker("uuid4")
    name = factory.Faker("name")

    class Meta:
        model = dict


class CoverJSONFactory(factory.Factory):
    original = factory.Faker("url")

    class Meta:
        model = dict


class AlbumJSONFactory(factory.Factory):
    id = factory.Sequence(int)
    mbid = factory.Faker("uuid4")
    title = factory.Faker("name")
    tracks = factory.Iterator([range(i) for i in range(1, 30)])
    artist = factory.SubFactory(ArtistJSONFactory)
    release_date = factory.Faker("date")
    cover = factory.SubFactory(CoverJSONFactory)

    class Meta:
        model = dict


class TrackJSONFactory(factory.Factory):
    id = factory.Sequence(int)
    mbid = factory.Faker("uuid4")
    title = factory.Faker("name")
    position = factory.Faker("pyint")
    duration = factory.Faker("pyint")
    creation_date = factory.Faker("date")
    bitrate = factory.Iterator([i * 1000 for i in (128, 256, 360)])
    artist = factory.SubFactory(ArtistJSONFactory)
    album = factory.SubFactory(AlbumJSONFactory)

    class Meta:
        model = dict


class ArtistFactory(factory.Factory):
    class Meta:
        model = models.Artist