Skip to content

Commit

Permalink
Merge pull request #28 from aanil/add_tests
Browse files Browse the repository at this point in the history
Fix existing, add more tests and make them run with Github actions
  • Loading branch information
aanil authored Jan 4, 2024
2 parents 39e0486 + 0adc5b1 commit be38851
Show file tree
Hide file tree
Showing 8 changed files with 617 additions and 151 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Run tests on push

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r tests/requirements-test.txt
pip install pytest pytest-cov
- name: Test with pytest
run: |
python -m pytest --cov=daily_read tests
21 changes: 5 additions & 16 deletions daily_read/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@
log = logging.getLogger(__name__)


STATUS_PRIORITY = {
1: "Samples Received",
2: "Reception Control finished",
3: "Library QC finished",
4: "All Samples Sequenced",
5: "All Raw data Delivered",
}

STATUS_PRIORITY_REV = {v: k for k, v in STATUS_PRIORITY.items()}


@click.group(context_settings=dict(help_option_names=["-h", "--help"]))
def daily_read_cli():
pass
Expand Down Expand Up @@ -98,12 +87,12 @@ def generate_all(upload=False, develop=False):
nr_orderers += 1
if nr_orderers > 4 and develop:
break
modified_orders = op.process_orders(STATUS_PRIORITY_REV)
modified_orders = op.process_orders(config_values.STATUS_PRIORITY_REV)
daily_rep = daily_read.daily_report.DailyReport()

for owner in modified_orders:
if upload:
report = daily_rep.populate_and_write_report(owner, modified_orders[owner], STATUS_PRIORITY)
report = daily_rep.populate_and_write_report(owner, modified_orders[owner], config_values.STATUS_PRIORITY)
# Publish reports
for status in modified_orders[owner]["projects"].keys():
for project in modified_orders[owner]["projects"][status]:
Expand All @@ -118,7 +107,7 @@ def generate_all(upload=False, develop=False):
report = daily_rep.populate_and_write_report(
owner,
modified_orders[owner],
STATUS_PRIORITY,
config_values.STATUS_PRIORITY,
out_dir=config_values.REPORTS_LOCATION,
)

Expand Down Expand Up @@ -165,12 +154,12 @@ def generate_single(project, include_older=False):
sys.exit(1)

op.get_orders(orderer=orderer)
filtered_orders = op.process_orders(STATUS_PRIORITY_REV)
filtered_orders = op.process_orders(config_values.STATUS_PRIORITY_REV)
daily_rep = daily_read.daily_report.DailyReport()

for owner, owner_orders in filtered_orders.items():
_ = daily_rep.populate_and_write_report(
owner, owner_orders, STATUS_PRIORITY, out_dir=config_values.REPORTS_LOCATION
owner, owner_orders, config_values.STATUS_PRIORITY, out_dir=config_values.REPORTS_LOCATION
)

log.info(f"Wrote report to {config_values.REPORTS_LOCATION}")
9 changes: 9 additions & 0 deletions daily_read/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ def __init__(self):
self.FETCH_FROM_NGIS = os.getenv("DAILY_READ_FETCH_FROM_NGIS")
self.FETCH_FROM_SNPSEQ = os.getenv("DAILY_READ_FETCH_FROM_SNPSEQ")
self.FETCH_FROM_UGC = os.getenv("DAILY_READ_FETCH_FROM_UGC")
self.STATUS_PRIORITY = {
0: "None",
1: "Samples Received",
2: "Reception Control finished",
3: "Library QC finished",
4: "All Samples Sequenced",
5: "All Raw data Delivered",
}
self.STATUS_PRIORITY_REV = {v: k for k, v in self.STATUS_PRIORITY.items()}
5 changes: 4 additions & 1 deletion tests/.test.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Test configuration variables

DAILY_READ_ORDER_PORTAL_URL="https://orderportal.example.com"
DAILY_READ_ORDER_PORTAL_URL="https://orderportal.example.com/"
DAILY_READ_ORDER_PORTAL_API_KEY='fake12349183o18390301'
DAILY_READ_DATA_LOCATION = "tests/test_data_location"
DAILY_READ_REPORTS_LOCATION='tests/test_reports_location'
DAILY_READ_FETCH_FROM_NGIS = true
DAILY_READ_FETCH_FROM_SNPSEQ = true
DAILY_READ_FETCH_FROM_UGC = true
#DAILY_READ_LOG_LOCATION='tests/log_location'
Loading

0 comments on commit be38851

Please sign in to comment.