Skip to content

Commit

Permalink
init pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
WardDeb committed Jul 15, 2024
1 parent 23c7485 commit c7a5a3f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/pip.yml → .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: install
name: test
on: [push, pull_request]
jobs:
pip:
Expand All @@ -9,4 +9,6 @@ jobs:
with:
python-version: '3.12'
cache: 'pip'
- run: pip install .
- run: |
pip install .
pytest
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ dependencies = [
"pyyaml >= 6.0",
"rich_click >= 1.8.3",
"dominate >= 2.9.1",
"tabulate >= 0.9.0"
"tabulate >= 0.9.0",
"pytest >= 8.2.2"
]

[project.scripts]
Expand Down
60 changes: 60 additions & 0 deletions tests/test_findFinishedFlowCells.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from pathlib import Path
import pytest
import configparser
import urllib3
from BRB.findFinishedFlowCells import flowCellProcessed, markFinished, queryParkour


@pytest.fixture(scope='session')
def ifs(tmp_path_factory):
fp = tmp_path_factory.mktemp("flowcells")
Path(fp,"fc_fin").mkdir()
Path(fp, "fc_fin", "analysis.done").touch()
Path(fp,"fc_unfin").mkdir()
return fp


def create_conf(l = []):
'''
sets up a config, where every list (_l) in l gets set in config as :
config[_l[0]] = {_l[1]: _l[2]}
Additionaly some garbage values for parkour API gets set
'''
config = configparser.ConfigParser()
config['Parkour'] = {
"QueryURL": "https://parkour-demo.ie-freiburg.mpg.de/nonext_api",
"user": "jefke",
"password": "123",
"cert": ""
}
config['Options'] = {'runID': '150416_SN7001180_0196_BC605HACXX'}
for _l in l:
config[_l[0]] = {_l[1]: _l[2]}
return config

class TestfindFinishedFlowCells:
def test_flowCellProcessed(self, ifs):
config = create_conf([
['Paths', 'baseData', ifs],
['Options', 'runID', 'fc_fin']
])
assert flowCellProcessed(config) == True
config = create_conf([
['Paths', 'baseData', ifs],
['Options', 'runID', 'fc_unfin']
])
assert flowCellProcessed(config) == False

def test_markFinished(self, ifs):
config = create_conf([
['Paths', 'baseData', ifs],
['Options', 'runID', 'fc_unfin'],
])
markFinished(config)
assert Path(ifs, 'fc_unfin', 'analysis.done').exists()

def test_queryParkour(self):
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
config = create_conf()
assert len(queryParkour(config)) == 0

0 comments on commit c7a5a3f

Please sign in to comment.