Skip to content

Commit 9b01595

Browse files
BDD Tests for py-ard
BDD Tests for py-ard
1 parent 70a2734 commit 9b01595

File tree

10 files changed

+122
-0
lines changed

10 files changed

+122
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ ENV/
104104
*.txt
105105
*.pickle
106106
*.zip
107+
108+
# BDD Testing
109+
testing/
110+
!test-requirements.txt

README.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ Install from PyPi
3434
3535
pip install py-ard
3636
37+
Testing
38+
39+
-------
40+
To run behavior-driven development (BDD) tests locally via the behave framework,
41+
you'll need to set up a virtual environment.
42+
43+
.. code-block::
44+
# Virtual environment setup
45+
python3 -m venv testing
46+
source testing/bin/activate
47+
pip install --upgrade pip
48+
pip install -r test-requirements.txt
49+
50+
# Running Behave and all BDD tests
51+
behave
3752
3853
Example
3954
-------

behave.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[behave]
2+
paths=tests
3+
format=pretty
4+
show_snippets=false
5+
6+
; Development
7+
stop=true

test-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
behave==1.2.6
2+
pandas==0.25.1
3+
PyHamcrest==2.0.2

tests/environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pyard import ARD
2+
3+
def before_all(context):
4+
context.ard = ARD(verbose=True)

tests/features/allele.feature

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Feature: Alleles
2+
3+
Scenario Outline:
4+
5+
Given the allele as <Allele>
6+
When reducing on the <Level> level
7+
Then the reduced allele is found to be <Redux Allele>
8+
9+
Examples:
10+
| Allele | Level | Redux Allele |
11+
| A*01:01:01 | G | A*01:01:01G |
12+
| A*01:01:01 | lg | A*01:01g |
13+
| A*01:01:01 | lgx | A*01:01 |
14+
15+
| HLA-A*01:01:01 | G | HLA-A*01:01:01G |
16+
| HLA-A*01:01:01 | lg | HLA-A*01:01g |
17+
| HLA-A*01:01:01 | lgx | HLA-A*01:01 |
18+
19+
| DRB1*14:05:01 | lgx | DRB1*14:05 |
20+
| DRB1*14:05:01 | lg | DRB1*14:05g |
21+
22+
| DRB1*14:06:01 | lgx | DRB1*14:06 |
23+
| DRB1*14:06:01 | lg | DRB1*14:06g |

tests/features/glstring.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Feature: GL (Genotype List) Strings
2+
3+
Scenario Outline:
4+
5+
Given the allele as <Allele>
6+
When reducing on the <Level> level (ambiguous)
7+
Then the reduced allele is found to be <Redux Allele>
8+
9+
Examples:
10+
| Allele | Level | Redux Allele |
11+
| A*01:01:01:01+A*01:01:01:01 | G | A*01:01:01G+A*01:01:01G |
12+
| HLA-A*01:01:01:01+HLA-A*01:01:01:01 | G | HLA-A*01:01:01G+HLA-A*01:01:01G |
13+
| A*01:01:01:01+A*01:01:01:01 | lg | A*01:01g+A*01:01g |
14+
| HLA-A*01:01:01:01+HLA-A*01:01:01:01 | lg | HLA-A*01:01g+HLA-A*01:01g |
15+
| A*01:01:01:01+A*01:01:01:01 | lgx | A*01:01+A*01:01 |
16+
| HLA-A*01:01:01:01+HLA-A*01:01:01:01 | lgx | HLA-A*01:01+HLA-A*01:01 |
17+
| A*01:01+A*01:01^B*07:02+B*07:02 | G | A*01:01:01G+A*01:01:01G^B*07:02:01G+B*07:02:01G |
18+
| A*01:01+A*01:01^B*07:02+B*07:02 | lg | A*01:01g+A*01:01g^B*07:02g+B*07:02g |
19+
| A*01:01~B*07:02+A*01:01~B*07:02 | G | A*01:01:01G~B*07:02:01G+A*01:01:01G~B*07:02:01G |
20+
| A*01:01~B*07:02+A*01:01~B*07:02 | lg | A*01:01g~B*07:02g+A*01:01g~B*07:02g |
21+
| A*01:01~B*07:02+A*01:01~B*07:02\|A*02:01~B*07:02+A*02:01~B*07:02 | lg | A*01:01g~B*07:02g+A*01:01g~B*07:02g\|A*02:01g~B*07:02g+A*02:01g~B*07:02g |

tests/features/mac.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Feature: MAC (Multiple Allele Code)
2+
3+
Scenario Outline:
4+
5+
Given the allele as <Allele>
6+
When reducing on the <Level> level (ambiguous)
7+
Then the reduced allele is found to be <Redux Allele>
8+
9+
Examples:
10+
| Allele | Level | Redux Allele |
11+
| A*01:AB | G | A*01:01:01G/A*01:02 |
12+
| A*01:AB | lgx | A*01:01/A*01:02 |
13+
| HLA-A*01:AB | G | HLA-A*01:01:01G/HLA-A*01:02 |
14+
| HLA-A*01:AB | lgx | HLA-A*01:01/HLA-A*01:02 |

tests/features/p_g_group.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: P and G Groups
2+
3+
Scenario Outline:
4+
5+
Given the allele as <Allele>
6+
When reducing on the <Level> level (ambiguous)
7+
Then the reduced allele is found to be <Redux Allele>
8+
9+
Examples:
10+
| Allele | Level | Redux Allele |
11+
| A*02:01P | lgx | A*02:01 |
12+
| A*02:01:01G | lgx | A*02:01 |

tests/steps/redux_allele.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from hamcrest import assert_that, is_
2+
3+
@given('the allele as {allele}')
4+
def step_impl(context, allele):
5+
context.allele = allele
6+
7+
@when('reducing on the {level} level')
8+
def step_impl(context, level):
9+
context.level = level
10+
context.redux_allele = context.ard.redux(context.allele, level)
11+
12+
@when('reducing on the {level} level (ambiguous)')
13+
def step_impl(context, level):
14+
context.level = level
15+
context.redux_allele = context.ard.redux_gl(context.allele, level)
16+
17+
@then('the reduced allele is found to be {redux_allele}')
18+
def step_impl(context, redux_allele):
19+
assert_that(context.redux_allele, is_(redux_allele))

0 commit comments

Comments
 (0)