Skip to content

Commit

Permalink
test: add dedicated compression test when supported (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCrab13 authored Mar 10, 2024
1 parent c036350 commit 3b6dfda
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
25 changes: 6 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,25 @@ jobs:
- version: "3.10"
toxenv: py310
- version: "3.11"
toxenv: py311
toxenv: py311,cli
include:
- os: windows-latest
python:
version: "3.11"
toxenv: py311
toxenv: py311,cli
steps:
- uses: actions/checkout@v4.1.0
- name: Set up Python ${{ matrix.python.version }}
uses: actions/setup-python@v4.7.0
with:
python-version: ${{ matrix.python.version }}
- name: Install gcab
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install -y gcab
- name: Install dependencies
run: pip install tox
- name: Run tests
run: tox -e ${{ matrix.python.toxenv }} --skip-missing-interpreters false

functional:
runs-on: ubuntu-22.04
strategy:
matrix:
toxenv: [cli]
steps:
- uses: actions/checkout@v4.1.0
- name: Set up Python
uses: actions/setup-python@v4.7.0
with:
python-version: "3.11"
- name: Install dependencies
run: pip install tox
- name: Run tests
run: tox -e ${{ matrix.toxenv }} -- --override-ini='log_cli=True'
run: tox -e ${{ matrix.python.toxenv }} -- --override-ini='log_cli=True'

coverage:
runs-on: ubuntu-22.04
Expand Down
37 changes: 37 additions & 0 deletions tests/cli/test_add.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from unittest import mock

import pytest
Expand All @@ -11,6 +12,7 @@
ERROR_UNEXPECTED,
SUCCESS,
)
from pdbstore.io import cab


def test_incomplete_no_action():
Expand Down Expand Up @@ -155,3 +157,38 @@ def test_no_compression(tmp_store_dir, test_data_native_dir):

# Test with direct call to main function
assert cli.main(["add"] + argv) == ERROR_GENERAL


@pytest.mark.skipif(cab.compress is None, reason="compression not available")
def test_valid_compression(tmp_store_dir, test_data_native_dir):
"""test add command when compression is supported"""
argv = [
"--store-dir",
str(tmp_store_dir),
"--product-name",
"myproduct",
"--product-version",
"1.0.0",
"--compress",
str(test_data_native_dir / "dummyapp.pdb"),
]

# Test through direct command-line
with mock.patch(
"sys.argv",
["pdbstore", "add"] + argv,
):
assert cli.main() == SUCCESS

stored_path: Path = (
tmp_store_dir
/ "dummyapp.pdb"
/ "DBF7CE25C6DC4E0EA9AD889187E296A21"
/ "dummyapp.pd_"
)
assert stored_path.exists() is True
with stored_path.open("rb") as fpsp:
assert fpsp.read(4) == b"MSCF"

# Test with direct call to main function
assert cli.main(["add"] + argv) == SUCCESS

0 comments on commit 3b6dfda

Please sign in to comment.