File: test_utils.py

package info (click to toggle)
mopidy 3.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,608 kB
  • sloc: python: 16,656; sh: 159; makefile: 127
file content (20 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pytest

from mopidy.audio import utils
from mopidy.internal.gi import Gst


class TestCreateBuffer:
    def test_creates_buffer(self):
        buf = utils.create_buffer(b"123", timestamp=0, duration=1000000)

        assert isinstance(buf, Gst.Buffer)
        assert buf.pts == 0
        assert buf.duration == 1000000
        assert buf.get_size() == len(b"123")

    def test_fails_if_data_has_zero_length(self):
        with pytest.raises(ValueError) as excinfo:
            utils.create_buffer(b"", timestamp=0, duration=1000000)

        assert "Cannot create buffer without data" in str(excinfo.value)