Skip to content

Commit

Permalink
fix: complete py port test mod
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrogzi committed Aug 5, 2024
1 parent 3fbe320 commit ec7ae6a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 20 deletions.
9 changes: 9 additions & 0 deletions py-gtfsort/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ homepage = "https://github.com/alejandrogz/gtfsort"
[tool.maturin]
features = ["pyo3/extension-module"]

[tool.hatch.envs.default]
dependencies = [
"pandas",
"pytest",
]

[tool.hatch.envs.default.scripts]
test = "pytest {args:test}"

20 changes: 0 additions & 20 deletions py-gtfsort/test/gtfsort.py

This file was deleted.

43 changes: 43 additions & 0 deletions py-gtfsort/test/test_gtfsort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import gtfsortpy
import os
import pandas as pd
import pytest
from typing import Tuple
import unittest

NTHREADS = 4

def get_test_file() -> Tuple[str]:
tmp = gtfsortpy.get_test_file()
out = tmp + '.sorted'
return (tmp, out)

def main():
tmp, out = get_test_file()
status = gtfsortpy.sort(tmp, out, NTHREADS)
return status

class TestGtf(unittest.TestCase):

def setUp(self):
self.tmp, self.out = get_test_file()
self.status = gtfsortpy.sort(self.tmp, self.out, NTHREADS)

def test_file_creation(self):
self.assertTrue(os.path.isfile(self.out))

def test_status_output(self):
self.assertIsNotNone(self.status)

def test_sorted_file_line_count(self):
expected_line_count = 333875
with open(self.out, 'r') as f:
line_count = len(f.readlines())

self.assertEqual(line_count, expected_line_count)

def test_sorted_file_order(self):
rule = ['GL456221.1', 'chr1', 'chr2', 'chr3', 'chr5', 'chrM']
chrom_order = pd.read_csv(self.out, sep='\t', usecols=[0], header=None)[0].unique().tolist()

self.assertEqual(chrom_order, rule)

0 comments on commit ec7ae6a

Please sign in to comment.