-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create unit_test_workflow.yml
- Loading branch information
Showing
7 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
# Git | ||
.git | ||
.gitignore | ||
|
||
# Text | ||
README.md | ||
Dockerfile | ||
LICENSE | ||
LICENSE | ||
|
||
# Test Suite | ||
tests/ | ||
__init__.py | ||
__main__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python application | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.12] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r ./requirements.txt | ||
- name: Test with unittest | ||
run: | | ||
python -m tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import unittest | ||
|
||
if __name__ == '__main__': | ||
test_utils = unittest.TestLoader().discover('tests') | ||
unittest.TextTestRunner().run(test_utils) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
content: | ||
video_ids_multiple: [ # Replace with Youtube video IDs to play | ||
"string1", | ||
"string2", | ||
"string3" | ||
] | ||
video_ids_single: ["string3"] | ||
video_ids_empty: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import unittest | ||
from src.util import select_random, load_yaml | ||
|
||
class TestUtils(unittest.TestCase): | ||
''' | ||
Test select_random function | ||
''' | ||
def test_select_random(self): | ||
arr = [1, 2, 3, 4, 5] | ||
self.assertIn(select_random(arr), arr) | ||
|
||
def test_select_random_empty(self): | ||
arr = [] | ||
with self.assertRaises(IndexError): | ||
select_random(arr) | ||
|
||
''' | ||
Test load_yaml function | ||
''' | ||
data = load_yaml('tests/test_data.yaml') | ||
def test_load_yaml_multiple(self): | ||
videos = self.data['content']['video_ids_multiple'] | ||
self.assertIsInstance(videos, list) | ||
for video in videos: | ||
self.assertIsInstance(video, str) | ||
|
||
def test_load_yaml_single(self): | ||
videos = self.data['content']['video_ids_single'] | ||
self.assertIsInstance(videos, list) | ||
for video in videos: | ||
self.assertIsInstance(video, str) | ||
|
||
def test_load_yaml_empty(self): | ||
videos = self.data['content']['video_ids_empty'] | ||
self.assertIsInstance(videos, list) | ||
self.assertEqual(len(videos), 0) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|