aboutsummaryrefslogtreecommitdiff
path: root/tests/__init__.py
blob: b6156817c4d6723944730d4d811b0406b6cf832e (plain)
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
import os
import numpy

# core always has to be imported first
import avp.core
from avp.toolkit.ffmpeg import readAudioFile
from pytest import fixture


@fixture
def audioData():
    """Fixture that gives a tuple of (completeAudioArray, duration)"""
    soundFile = getTestDataPath("test.ogg")
    yield readAudioFile(soundFile, MockVideoWorker())


def getTestDataPath(filename):
    """Get path to a file in the ./data directory"""
    tests_dir = os.path.dirname(os.path.abspath(__file__))
    return os.path.join(tests_dir, "data", filename)


class MockSignal:
    """Pretends to be a pyqtSignal"""

    def emit(self, *args):
        pass


class MockVideoWorker:
    """Pretends to be a video thread worker"""

    progressBarSetText = MockSignal()
    progressBarUpdate = MockSignal()


def imageDataSum(image):
    """Get sum of raw data of a Pillow Image object"""
    return numpy.asarray(image, dtype="int32").sum(dtype="int32")