Skip to content

Commit 77b0e71

Browse files
committed
Use uv in GitHub Action
1 parent 523fb54 commit 77b0e71

File tree

2 files changed

+48
-21
lines changed

2 files changed

+48
-21
lines changed

.github/workflows/python-tests.yml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: BDD and Unit Tests
52

63
on:
@@ -10,24 +7,29 @@ on:
107
branches: [ master ]
118

129
jobs:
13-
build:
14-
10+
run-tests:
11+
name: python
1512
runs-on: ubuntu-latest
1613

1714
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up Python 3.9
20-
uses: actions/setup-python@v2
21-
with:
22-
python-version: 3.9
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
27-
if [ -f requirements-tests.txt ]; then pip install -r requirements-tests.txt; fi
28-
- name: Test with pytest
29-
run: |
30-
pytest
31-
- name: Run BDD Tests
32-
run: |
33-
behave
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version-file: ".python-version"
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v6
24+
with:
25+
# Install a specific version of uv.
26+
version: "0.8.15"
27+
28+
- name: Install the project
29+
run: uv sync --locked --group=test
30+
31+
- name: Run pytests
32+
run: uv run pytest
33+
34+
- name: Run BDD Tests
35+
run: uv run behave

tests/unit/test_my_project_template.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"""Tests for `my_project_template` package."""
2727

2828
import pytest
29+
from my_project_template.algorithm.match import slug_match
30+
from my_project_template.model.slug import SLUG
31+
from my_project_template.model.allele import Allele
2932

3033

3134
@pytest.fixture
@@ -40,3 +43,25 @@ def supported_genes():
4043
def test_content(supported_genes):
4144
"""Sample pytest test function with the pytest fixture as an argument."""
4245
assert "HLA-A" in supported_genes
46+
47+
48+
def test_slug_match_identical_slugs():
49+
"""Test that identical SLUGs match."""
50+
allele1 = Allele("HLA-A", "HLA-A*01:01")
51+
allele2 = Allele("HLA-A", "HLA-A*02:01")
52+
slug1 = SLUG(allele1, allele2)
53+
slug2 = SLUG(allele1, allele2)
54+
55+
assert slug_match(slug1, slug2) is True
56+
57+
58+
def test_slug_match_different_slugs():
59+
"""Test that different SLUGs do not match."""
60+
allele1 = Allele("HLA-A", "HLA-A*01:01")
61+
allele2 = Allele("HLA-A", "HLA-A*02:01")
62+
allele3 = Allele("HLA-A", "HLA-A*03:01")
63+
64+
slug1 = SLUG(allele1, allele2)
65+
slug2 = SLUG(allele1, allele3)
66+
67+
assert slug_match(slug1, slug2) is False

0 commit comments

Comments
 (0)