Skip to content

Commit

Permalink
Add tests for lsblk thing and add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lvps committed Nov 15, 2024
1 parent 6bdf72c commit 4fa285d
Show file tree
Hide file tree
Showing 4 changed files with 523 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python Tests

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
- name: Run tests
run: pytest tests
6 changes: 5 additions & 1 deletion basilico.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,11 @@ def _get_last_linux_partition_path_and_number(dev: str) -> tuple[str, str] | tup
# PARTTYPENAME could be useful, too
output = subprocess.getoutput(f"lsblk -o PATH,PARTN,PARTTYPE -J {dev}")
jsonized = json.loads(output)
for i, entry in enumerate(jsonized["blockdevices"]):
return CommandRunner._get_last_linux_partition_path_and_number_from_lsblk(jsonized)

@staticmethod
def _get_last_linux_partition_path_and_number_from_lsblk(lsblk_json: dict) -> tuple[str, str] | tuple[None, None]:
for i, entry in enumerate(lsblk_json["blockdevices"]):
if entry["path"]: # lsblk also returns the device itself, which has no partitions
# GPT or MBR Linux partition ID
if entry["parttype"] == "0fc63daf-8483-4772-8e79-3d69d8477de4" or entry["parttype"] == "0x83":
Expand Down
Empty file added tests/__init__.py
Empty file.
Loading

0 comments on commit 4fa285d

Please sign in to comment.