forked from 0xHJK/music-dl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_music.py
More file actions
42 lines (34 loc) · 952 Bytes
/
Copy pathtest_music.py
File metadata and controls
42 lines (34 loc) · 952 Bytes
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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author: HJK
@file: test_music
@time: 2019-01-30
"""
import os
from music_dl.music import Music
def test_music(capsys):
music = Music()
music.id = 816477
music.title = "cheering"
music.singer = "crowd"
music.ext = "mp3"
music.album = "sample"
music.rate = 128
music.source = "sample"
music.duration = 28
music.outdir = "/tmp"
music.verbose = True
music.url = "https://github.com/0xHJK/music-dl/raw/master/static/sample.mp3"
assert music.avaiable
assert music.size == 0.42
assert music.duration == "0:00:28"
os.system("rm /tmp/*.mp3")
for i in range(10):
fix = "" if i == 0 else " (%d)" % i
assert music.fullname == "/tmp/crowd - cheering%s.mp3" % fix
open(music.fullname, "w").write("")
str(music)
music.download()
out, err = capsys.readouterr()
assert out.find("/tmp/crowd - cheering")