Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #23

Merged
merged 23 commits into from
Jul 6, 2023
Merged

Test #23

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1c9e5d8
fix : dummy driver added to tests
sepandhaghighi Jun 27, 2023
330211a
fix : function test added
sepandhaghighi Jun 27, 2023
162ad19
fix : pytest added to test.yml
sepandhaghighi Jun 27, 2023
d60264e
fix : pytest.ini file added
sepandhaghighi Jun 27, 2023
5fb77f8
fix : sudo privilege added to linux test
sepandhaghighi Jun 27, 2023
c82857c
fix : sudo privilege added to linux test
sepandhaghighi Jun 27, 2023
6bbf77e
fix : sudo privilege added to linux test
sepandhaghighi Jun 27, 2023
b3e5a19
fix : test system isolation
sepandhaghighi Jun 27, 2023
d2eff0f
fix : codecov action added to tests
sepandhaghighi Jun 27, 2023
e03ba98
fix : error tests added
sepandhaghighi Jun 28, 2023
3954c9e
fix : windows-2019 added to os-matrix
sepandhaghighi Jun 28, 2023
92497de
fix : macOS-11 added to os-matrix
sepandhaghighi Jun 28, 2023
a9c4426
fix : nava functions test updated
sepandhaghighi Jun 28, 2023
22c2c46
fix : one general exception removed from coverage
sepandhaghighi Jun 28, 2023
55dc6dd
fix : coverage config files added
sepandhaghighi Jun 28, 2023
d6d4dae
doc : CHANGELOG.md updated
sepandhaghighi Jun 28, 2023
b8a1caa
doc : CI badges updated
sepandhaghighi Jun 28, 2023
17324a2
doc : codecov badge added
sepandhaghighi Jun 28, 2023
27cbda8
doc : minor edit in codecov badge
sepandhaghighi Jun 28, 2023
91bb794
fix : minor edit in windows_test.yml
sepandhaghighi Jun 29, 2023
6bd15dd
fix : apt-get update added to linux test
sepandhaghighi Jun 29, 2023
fb7b1a3
fix : some extra app removed from linux test
sepandhaghighi Jun 29, 2023
3c2cfe9
change : sound trimed to its first 0.35s.
sadrasabouri Jun 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[run]
branch = True
omit =
*/nava/__main__.py
*/nava/__init__.py
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
pragma: no cover
64 changes: 64 additions & 0 deletions .github/workflows/linux_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Linux

on: [push, pull_request]

env:
TEST_PYTHON_VERSION: 3.9

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Installation
run: |
sudo python -m pip install --upgrade pip
sudo pip install -r requirements.txt
sudo python setup.py install
- name: First test
run: |
sudo nava
- name: Install ALSA
run: |
sudo apt-get update
sudo apt-get install alsa-utils
sudo apt-get install alsa-tools
sudo apt-get install alsa-firmware-loaders
sudo apt-get install alsa-oss
sudo apt-get install -y software-properties-common
sudo apt-get install linux-modules-extra-$(uname -r)
sudo modprobe snd-dummy
- name: Test requirements Installation
run: |
sudo python others/requirements-splitter.py
sudo pip install --upgrade --upgrade-strategy=only-if-needed -r test-requirements.txt
- name: Test with pytest
run: |
sudo python -m pytest --cov=nava --cov-report=term
- name: Other tests
run: |
sudo python -m vulture nava/ others/ setup.py --min-confidence 65 --exclude=__init__.py --sort-by-size
sudo python -m bandit -r nava -s B404,B603,B605,B607
sudo python -m pydocstyle -v --match-dir=nava
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Version check
run: |
python others/version_check.py
if: matrix.python-version == env.TEST_PYTHON_VERSION
16 changes: 9 additions & 7 deletions .github/workflows/test.yml → .github/workflows/macOS_test.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI
name: macOS

on: [push, pull_request]

env:
TEST_PYTHON_VERSION: 3.9
TEST_OS: 'ubuntu-20.04'

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macOS-latest]
os: [macOS-12, macOS-11]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0]
steps:
- uses: actions/checkout@v2
Expand All @@ -35,14 +34,17 @@ jobs:
run: |
python others/requirements-splitter.py
pip install --upgrade --upgrade-strategy=only-if-needed -r test-requirements.txt
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Test with pytest
run: |
python -m pytest --cov=nava --cov-report=term
- name: Other tests
run: |
python -m vulture nava/ others/ setup.py --min-confidence 65 --exclude=__init__.py --sort-by-size
python -m bandit -r nava -s B404,B603,B605,B607
python -m pydocstyle -v --match-dir=nava
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Version check
run: |
python others/version_check.py
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
if: matrix.python-version == env.TEST_PYTHON_VERSION
63 changes: 63 additions & 0 deletions .github/workflows/windows_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Windows

on: [push, pull_request]

env:
TEST_PYTHON_VERSION: 3.9

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, windows-2019]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Installation
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
- name: First test
run: |
nava
- name: Install Scream
shell: powershell
run: |
Start-Service audio*
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.6/Scream3.6.zip -OutFile C:\Scream3.6.zip
Extract-7Zip -Path C:\Scream3.6.zip -DestinationPath C:\Scream
$cert = (Get-AuthenticodeSignature C:\Scream\Install\driver\Scream.sys).SignerCertificate
$store = [System.Security.Cryptography.X509Certificates.X509Store]::new("TrustedPublisher", "LocalMachine")
$store.Open("ReadWrite")
$store.Add($cert)
$store.Close()
cd C:\Scream\Install\driver
C:\Scream\Install\helpers\devcon install Scream.inf *Scream
- name: Test requirements Installation
run: |
python others/requirements-splitter.py
pip install --upgrade --upgrade-strategy=only-if-needed -r test-requirements.txt
- name: Test with pytest
run: |
python -m pytest --cov=nava --cov-report=term
- name: Other tests
run: |
python -m vulture nava/ others/ setup.py --min-confidence 65 --exclude=__init__.py --sort-by-size
python -m bandit -r nava -s B404,B603,B605,B607
python -m pydocstyle -v --match-dir=nava
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
if: matrix.python-version == env.TEST_PYTHON_VERSION
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- `quote` decorator bug fixed
- `path_check` decorator bug fixed
- Test system modified
## [0.1] - 2023-06-10
### Added
- `README.md`
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<a href="https://badge.fury.io/py/nava">
<img src="https://badge.fury.io/py/nava.svg" alt="PyPI version" height="18">
</a>
<a href="https://codecov.io/gh/openscilab/nava">
<img src="https://codecov.io/gh/openscilab/nava/branch/main/graph/badge.svg" alt="Codecov">
</a>
<a href="https://discord.gg/MCbPKCFBs3">
<img src="https://img.shields.io/discord/1064533716615049236.svg" alt="Discord Channel">
</a>
Expand Down Expand Up @@ -59,9 +62,19 @@ Nava is a Python library that allows users to play sound in Python without any d
<td align="center">dev</td>
</tr>
<tr>
<td align="center">CI</td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/CI/badge.svg?branch=main"></td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/CI/badge.svg?branch=dev"></td>
<td align="center">Linux CI</td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/Linux/badge.svg?branch=main"></td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/Linux/badge.svg?branch=dev"></td>
</tr>
<tr>
<td align="center">Windows CI</td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/Windows/badge.svg?branch=main"></td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/Windows/badge.svg?branch=dev"></td>
</tr>
<tr>
<td align="center">macOS CI</td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/macOS/badge.svg?branch=main"></td>
<td align="center"><img src="https://github.com/openscilab/nava/workflows/macOS/badge.svg?branch=dev"></td>
</tr>
</table>

Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: up
range: "70...100"
status:
patch:
default:
enabled: no
project:
default:
threshold: 1%
2 changes: 1 addition & 1 deletion nava/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,5 @@ def play(sound_path):
__play_mac(sound_path)
else:
__play_linux(sound_path)
except Exception:
except Exception: # pragma: no cover
raise NavaBaseError(SOUND_FILE_PLAY_ERROR)
Binary file added others/test.wav
Binary file not shown.
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# content of pytest.ini
[pytest]
addopts = --doctest-modules --ignore=others
doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
12 changes: 12 additions & 0 deletions test/error_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
"""
>>> from nava import play
>>> play("test.wav")
Traceback (most recent call last):
...
nava.errors.NavaBaseError: Given sound file doesn't exist.
>>> play(1)
Traceback (most recent call last):
...
nava.errors.NavaBaseError: Sound file's path should be a string.
"""
14 changes: 14 additions & 0 deletions test/function_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
"""
>>> import os
>>> from nava import play
>>> play(os.path.join("others", "test.wav"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find the exact place in which we test the correct performance of the play function. (As you said, comparing waveforms and etc.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github Action does not install any drivers by default. After installing the driver, if the system succeeds in playing the file, no error will occur. That's enough at the moment.

>>> from nava.functions import nava_help
>>> nava_help()
<BLANKLINE>
A Python library for playing sound everywhere natively and securely.
<BLANKLINE>
<BLANKLINE>
Repo : https://github.com/openscilab/nava
Webpage : https://openscilab.com/
"""