Skip to content

Commit

Permalink
Update test.yml and add test files
Browse files Browse the repository at this point in the history
  • Loading branch information
SohamTilekar committed Feb 4, 2024
1 parent 5f0e68c commit 7700250
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.11, 3.12]
os: [windows-latest]
python-version: [3.12]
name: Test
runs-on: ${{ matrix.os }}

Expand Down
97 changes: 97 additions & 0 deletions test/test_audioclip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# import pytest
# import numpy as np
# from vidiopy import AudioClip


# def test_audio_clip_init():
# clip = AudioClip()
# assert clip.fps is None
# assert clip._original_dur is None
# assert clip._audio_data is None
# assert clip.channels is None
# assert clip._st == 0.0
# assert clip._ed is None

# clip = AudioClip(5, 44100)
# assert clip.fps == 44100
# assert clip._original_dur == 5.0
# assert clip._audio_data is None
# assert clip.channels is None
# assert clip._st == 0.0
# assert clip._ed == 5.0


# def test_audio_clip_audio_data():
# clip = AudioClip()
# with pytest.raises(ValueError):
# _ = clip.audio_data

# clip.audio_data = np.array([1, 2, 3])
# assert np.array_equal(clip.audio_data, np.array([1, 2, 3]))


# def test_audio_clip_set_data():
# clip = AudioClip()
# clip.set_data(np.array([1, 2, 3]))
# assert np.array_equal(clip._audio_data, np.array([1, 2, 3]))


# def test_audio_clip_duration():
# clip = AudioClip(5, 44100)
# assert clip.duration == 5.0

# with pytest.raises(AttributeError):
# clip.duration = 10


# def test_audio_clip_start():
# clip = AudioClip()
# assert clip.start == 0.0

# clip.start = 1.0
# assert clip.start == 1.0


# def test_audio_clip_end():
# clip = AudioClip(5, 44100)
# assert clip.end == 5.0

# clip.end = 10.0
# assert clip.end == 10.0


# def test_audio_clip_get_frame_at_t():
# clip = AudioClip(5, 44100)
# clip.set_data(np.array([1, 2, 3, 4, 5]))

# with pytest.raises(ValueError):
# _ = clip.get_frame_at_t(6)

# clip = AudioClip(5, 44100)
# clip.set_data(np.array([1, 2, 3, 4, 5]))
# assert clip.get_frame_at_t(1) == 1


# def test_audio_clip_iterate_frames_at_fps():
# clip = AudioClip(5, 44100)
# clip.set_data(np.array([1, 2, 3, 4, 5]))

# with pytest.raises(ValueError):
# _ = list(clip.iterate_frames_at_fps())

# clip = AudioClip(5, 44100)
# clip.set_data(np.array([1, 2, 3, 4, 5]))
# assert list(clip.iterate_frames_at_fps(44100)) == [1, 2, 3, 4, 5]


# def test_audio_clip_iterate_all_frames():
# clip = AudioClip()
# clip.set_data(np.array([1, 2, 3, 4, 5]))
# assert list(clip.iterate_all_frames()) == [1, 2, 3, 4, 5]


# def test_audio_clip_fl_frame_transform():
# clip = AudioClip()
# clip.set_data(np.array([1, 2, 3, 4, 5]))
# clip.fl_frame_transform(lambda x: x * 2)
# assert np.array_equal(clip._audio_data, np.array([2, 4, 6, 8, 10]))
2 changes: 2 additions & 0 deletions test/test_videofileclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def clip_random_audio():
)
)
)
print(f"{pth=}, {os.path.exists(pth)=}")
return VideoFileClip(pth)


Expand All @@ -31,6 +32,7 @@ def clip_random_no_audio():
)
)
)
print(f"{pth=}, {os.path.exists(pth)=}")
return VideoFileClip(
pth,
audio=False,
Expand Down
4 changes: 2 additions & 2 deletions vidiopy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from vidiopy.config import *

print("Installing ffmpeg...")
install_ffmpeg()
print("ffmpeg installed successfully!")
x = install_ffmpeg()
print(f"ffmpeg installed successfully! at {x[0]} and {x[1]}")
else:
from vidiopy.__init__ import *

0 comments on commit 7700250

Please sign in to comment.