Skip to content

Commit

Permalink
Add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvolokha committed Feb 28, 2024
1 parent d3fb3fc commit c6217ea
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 29 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python application test
name: Python application tests

on:
push:
Expand All @@ -22,4 +22,11 @@ jobs:
make dependency
- name: Test with pytest
run: |
make testing
make testing
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ MANIFEST
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
# Unit tests / coverage reports
htmlcov/
.tox/
.nox/
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependency:

testing:
@echo "Testing code..."
pytest
pytest --cov=core --cov-report=xml tests/

build:
@echo "Creating binary..."
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyinstaller==6.4.0
argparse
pyzipper==0.3.6
pytest==8.0.2
pydub==0.25.1
numpy==1.26.4

pytest==8.0.2
coverage==7.4.3
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions test/test_encryption_core.py → tests/test_encryption_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import shutil

from core.encryption_core import EncryptionCore
from test.test_helper import audio_content_compare, binary_compare
from tests.test_helper import audio_content_compare, binary_compare


def test_encrypt_without_pass():
input_file = 'test/data/song_orig.mp3'
input_file = 'tests/data/song_orig.mp3'
out_file = 'out.mp3'
files = ['test/data/very_secret_doc.pdf']
files = ['tests/data/very_secret_doc.pdf']

core = EncryptionCore(
infile=input_file,
Expand All @@ -25,9 +25,9 @@ def test_encrypt_without_pass():


def test_encrypt_with_pass():
input_file = 'test/data/song_orig.mp3'
input_file = 'tests/data/song_orig.mp3'
out_file = 'out.mp3'
files = ['test/data/very_secret_doc.pdf']
files = ['tests/data/very_secret_doc.pdf']
password = 'myawesomepass'

core = EncryptionCore(
Expand All @@ -46,10 +46,10 @@ def test_encrypt_with_pass():


def test_decrypt_without_pass():
input_file = 'test/data/out_without_pwd.mp3'
input_file = 'tests/data/out_without_pwd.mp3'
out_folder = 'db0c7f89-f931-4e51-919d-1c91375f3742'
out_file = f'{out_folder}/very_secret_doc.pdf'
orig_file = 'test/data/very_secret_doc.pdf'
orig_file = 'tests/data/very_secret_doc.pdf'

core = EncryptionCore(infile=input_file)

Expand All @@ -63,10 +63,10 @@ def test_decrypt_without_pass():


def test_decrypt_with_pass():
input_file = 'test/data/out_with_password.mp3'
input_file = 'tests/data/out_with_password.mp3'
out_folder = '55b32fdd-5daf-4a05-bb54-8c5bfd17cc18'
out_file = f'{out_folder}/very_secret_doc.pdf'
orig_file = 'test/data/very_secret_doc.pdf'
orig_file = 'tests/data/very_secret_doc.pdf'
password = 'myawesomepass'

core = EncryptionCore(infile=input_file, passphrase=password)
Expand All @@ -81,7 +81,7 @@ def test_decrypt_with_pass():


def test_decrypt_with_invalid_pass():
input_file = 'test/data/out_with_password.mp3'
input_file = 'tests/data/out_with_password.mp3'
out_folder = '55b32fdd-5daf-4a05-bb54-8c5bfd17cc18'
password = 'invalidpasswprd'

Expand Down
16 changes: 8 additions & 8 deletions test/test_file_metadata.py → tests/test_file_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@


def test_file_metadata_setup():
filename = 'test.zip'
filepath = 'test/test.zip'
filename = 'tests.zip'
filepath = 'tests/tests.zip'

meta = FileMetaData(filename=filename, filepath=filepath)

Expand All @@ -14,7 +14,7 @@ def test_file_metadata_setup():


def test_file_metadata_setup_filename_only():
filename = 'test.zip'
filename = 'tests.zip'
meta = FileMetaData(filename=filename)

assert meta.filename == filename
Expand All @@ -23,9 +23,9 @@ def test_file_metadata_setup_filename_only():


def test_file_metadata_setup_all_fields():
filename = 'test.zip'
filename = 'tests.zip'
filename_json = 'test2.zip'
filepath = 'test/test.zip'
filepath = 'tests/tests.zip'
json_data = '{"filename": "' + filename_json + '"}'

meta = FileMetaData(filename=filename, filepath=filepath, json_data=json_data.encode())
Expand Down Expand Up @@ -74,12 +74,12 @@ def test_file_metadata_empty():


def test_to_json_string():
filename = 'test.zip'
filename = 'tests.zip'
meta = FileMetaData(filename=filename)


def test_encode():
filename = 'test.zip'
filename = 'tests.zip'
delimiter = '===='
json_data = json.dumps({"filename": filename})
expected = f"\n{delimiter}{json_data}{delimiter}\n".encode()
Expand All @@ -90,7 +90,7 @@ def test_encode():


def test_is_zip():
filename = 'test.rar'
filename = 'tests.rar'
meta = FileMetaData(filename=filename)

assert not meta.is_zip()
File renamed without changes.
10 changes: 5 additions & 5 deletions test/test_zip_helper.py → tests/test_zip_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tempfile

from core.zip_helper import create_tmp_zip_file, create_zip_from_paths, unzip_to_directory
from test.test_helper import is_uuid_v4
from tests.test_helper import is_uuid_v4


def test_create_tmp_zip_file():
Expand All @@ -23,7 +23,7 @@ def test_create_tmp_zip_file():


def test_zip_without_pass():
files = ['test/data/song_orig.mp3', 'test/data/very_secret_doc.pdf']
files = ['tests/data/song_orig.mp3', 'tests/data/very_secret_doc.pdf']
arch_name = 'test_arch'
arch_file = f'{arch_name}.zip'
create_zip_from_paths(paths=files, output_zip_file=arch_file)
Expand All @@ -40,7 +40,7 @@ def test_zip_without_pass():


def test_zip_with_pass_success():
files = ['test/data/song_orig.mp3', 'test/data/very_secret_doc.pdf']
files = ['tests/data/song_orig.mp3', 'tests/data/very_secret_doc.pdf']
arch_name = 'test_arch'
arch_file = f'{arch_name}.zip'
password = '1234'
Expand All @@ -59,7 +59,7 @@ def test_zip_with_pass_success():


def test_zip_with_pass_failed():
files = ['test/data/song_orig.mp3', 'test/data/very_secret_doc.pdf']
files = ['tests/data/song_orig.mp3', 'tests/data/very_secret_doc.pdf']
arch_name = 'test_arch'
arch_file = f'{arch_name}.zip'
password = '1234'
Expand All @@ -77,7 +77,7 @@ def test_zip_with_pass_failed():


def test_zip_with_pass_wrong():
files = ['test/data/song_orig.mp3', 'test/data/very_secret_doc.pdf']
files = ['tests/data/song_orig.mp3', 'tests/data/very_secret_doc.pdf']
arch_name = 'test_arch'
arch_file = f'{arch_name}.zip'
password = '1234'
Expand Down

0 comments on commit c6217ea

Please sign in to comment.