annotate tests.py @ 7:5eb2d5e3bf22

planemo upload for repository https://toolrepo.galaxytrakr.org/view/jpayne/bioproject_to_srr_2/556cac4fb538
author jpayne
date Sun, 05 May 2024 23:32:17 -0400
parents 2d4a2159c74b
children
rev   line source
jpayne@4 1 import pytest
jpayne@4 2
jpayne@4 3 from bio2srr import *
jpayne@4 4
jpayne@4 5
jpayne@4 6 def test_element_tree_xpath():
jpayne@4 7 from xml.etree import ElementTree as xml
jpayne@4 8 root = xml.fromstring(biosample_example)
jpayne@4 9 assert root.find(".//Id[@db='BioSample']") is not None
jpayne@4 10
jpayne@4 11 def test_flatten_biosample_xml():
jpayne@4 12 d = flatten_biosample_xml(biosample_example)
jpayne@4 13 assert d['biosample_accession'] == 'SAMN17131268'
jpayne@4 14 assert d['organism'] == 'Campylobacter jejuni'
jpayne@4 15 assert d['isolate'] == 'CFSAN091032'
jpayne@4 16
jpayne@4 17 def test_flatten_runs():
jpayne@4 18 d = list(flatten_runs(runs_example))
jpayne@4 19 assert len(d) == 2
jpayne@4 20
jpayne@4 21 def test_header_sort_override_consistency():
jpayne@4 22 import random
jpayne@4 23 L = ["C", "B", "A", "taxid", "bioproject"]
jpayne@4 24 L.sort(key=hso)
jpayne@4 25 # assert L[0] == "bioproject"
jpayne@4 26 A = L.copy()
jpayne@4 27 assert A == L
jpayne@4 28 R = []
jpayne@4 29 for _ in range(100):
jpayne@4 30 random.shuffle(A)
jpayne@4 31 A.sort(key=hso)
jpayne@4 32 R.append(A == L)
jpayne@4 33 assert all(R)
jpayne@4 34
jpayne@4 35 def test_hso_override():
jpayne@4 36 assert header_sort_override("bioproject", "taxid") < 0
jpayne@4 37 assert header_sort_override("taxid", "bioproject") > 0
jpayne@4 38 assert header_sort_override("taxid", "taxid") == 0
jpayne@4 39
jpayne@4 40 def test_hso_regular():
jpayne@4 41 assert header_sort_override("A", "B") < 0
jpayne@4 42 assert header_sort_override("B", "A") > 0