Codebase list eyed3 / 690735f
add non-trivial autopkgtests Gaetano Guerriero 2 years ago
3 changed file(s) with 77 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 #!/bin/sh
1 # autopkgtest check: Generate an .id3 file and read it back using eyed3 program
2 set -e
3
4 # create an empty .id3 file
5 tmpdir="${AUTOPKGTEST_TMP:-/tmp}"
6 id3file="$tmpdir"/cmd-id3-file-input-output.id3
7 > "$id3file"
8
9 # write some ID3 tags into the file
10 eyeD3 >/dev/null -Q\
11 -a artist \
12 -A album \
13 -t title \
14 -Y 2021 \
15 -n 42 "$id3file"
16
17 # read back written tags
18 output=$(eyeD3 "$id3file")
19
20 # test tags are found inoutput
21 test "${output#*artist: artist}" != "$output" || (echo 'ERROR: artist not found in written tags'; exit 1)
22 test "${output#*album: album}" != "$output" || (echo 'ERROR: album not found in written tags'; exit 1)
23 test "${output#*title: title}" != "$output" || (echo 'ERROR: title not found in written tags'; exit 1)
24 test "${output#*release date: 2021}" != "$output" || (echo 'ERROR: year not found in written tags'; exit 1)
25 test "${output#*track: 42}" != "$output" || (echo 'ERROR: track not found in written tags'; exit 1)
26
27
33
44 Test-Command: set -e ; for py in $(py3versions -r 2>/dev/null) ; do cd "$ADTTMP" ; echo "Testing with $py:" ; $py -c "import eyed3; print(eyed3)" ; done
55 Depends: python3-all, python3-eyed3
6 Restrictions: superficial
6 Restrictions: superficial
7
8 Tests: cmd-id3-file-input-output
9 Depends: eyed3
10
11 Tests: lib-id3-file-input-output
12 Depends: eyed3
0 #!/usr/bin/python3
1 # autopkgtest check: Generate an .id3 file and read it back using python-eyed3 library
2
3 import os
4 import datetime
5 import pathlib
6
7 import eyed3
8 import eyed3.id3
9 import eyed3.core
10
11 tmpdir = os.environ.get("AUTOPKGTEST_TMP") or "/tmp"
12 tmpf = pathlib.Path(tmpdir) / "lib-id3-file-input-output.id3"
13
14
15 def generate_id3_file(path):
16 with open(path, "wb"):
17 pass
18 f = eyed3.load(path)
19 f.initTag()
20
21 f.tag.artist = "artist"
22 f.tag.album = "album"
23 f.tag.title = "title"
24 f.tag.release_date = eyed3.core.Date(2021)
25 f.tag.track_num = (42, None)
26
27 f.tag.save()
28
29
30 def test_id3_file(path):
31 f = eyed3.load(path)
32 assert f.tag.artist == "artist"
33 assert f.tag.album == "album"
34 assert f.tag.title == "title"
35 assert f.tag.release_date == eyed3.core.Date(2021)
36 assert f.tag.track_num == (42, None)
37
38
39 if __name__ == "__main__":
40 generate_id3_file(tmpf)
41 test_id3_file(tmpf)