Skip to content

Commit

Permalink
Formatted for PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong1120 committed Jul 16, 2024
1 parent 978d516 commit aa08b08
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/stream_capture_test.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
from __future__ import annotations

import unittest

from src.stream_capture import StreamCapture


class TestStreamCapture(unittest.TestCase):

@classmethod
def setUpClass(cls):
# Setup
url = "tests/videos/test.mp4"
url = 'tests/videos/test.mp4'
capture_interval = 15
cls.stream_capture = StreamCapture(url, capture_interval)

def test_initialisation(self):
self.assertIsInstance(self.stream_capture, StreamCapture)

def test_capture_interval_update(self):
new_interval = 10
self.stream_capture.update_capture_interval(new_interval)
self.assertEqual(self.stream_capture.capture_interval, new_interval)

def test_select_quality_based_on_speed(self):
stream_url = self.stream_capture.select_quality_based_on_speed()
self.assertIsInstance(stream_url, (str, type(None)))

def test_check_internet_speed(self):
download_speed, upload_speed = self.stream_capture.check_internet_speed()
download_speed, upload_speed = (
self.stream_capture.check_internet_speed()
)
self.assertIsInstance(download_speed, float)
self.assertIsInstance(upload_speed, float)
self.assertGreaterEqual(download_speed, 0)
self.assertGreaterEqual(upload_speed, 0)

def test_execute_capture(self):
generator = self.stream_capture.execute_capture()
self.assertTrue(hasattr(generator, '__iter__'))
Expand All @@ -39,11 +45,12 @@ def test_execute_capture(self):
# Release resources
del frame
self.stream_capture.release_resources()

@classmethod
def tearDownClass(cls):
# Teardown or release resources if needed
cls.stream_capture.release_resources()


if __name__ == '__main__':
unittest.main()

0 comments on commit aa08b08

Please sign in to comment.