Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
tbooth committed Nov 20, 2024
1 parent d44e350 commit f16cc21
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
2 changes: 0 additions & 2 deletions compile_cell_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from smrtino import load_yaml, dump_yaml
from smrtino.ParseXML import get_metadata_info2
import json
from pprint import pprint

""" The info needed to report on a SMRT cell consists of several YAML files:
sc_data.yaml about the files in the upstream
Expand Down Expand Up @@ -73,7 +72,6 @@ def load_reports_zip(args_dict):
f" with {args_dict[f'{r}_report']}")
res[r] = json.load(jfh)

#pprint(res)
return res

def compile_json_reports(reports_dict, metadata_xml):
Expand Down
8 changes: 6 additions & 2 deletions make_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,16 @@ def format_cell(cdict, cell_link=None):

if 'reports' in cdict:
# New version v2
rep("", "## SMRTLink Sample and Reports", "")
rep('<dl class="dl-horizontal">')
rep("<dt>Project</dt>", f"<dl>{projects_str}</dl>")
rep('</dl>', '')

rep("## SMRTLink Sample and Reports", "")
rep('', *make_reports_table(cdict['reports']))

else:
# Old version
rep("", "## Basics", "")
rep("## Basics", "")
rep('<dl class="dl-horizontal">')
for k, v in sorted(cdict.items()):
if k == 'cell_uuid' and cell_link:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
_cstats:
- Barcode: foo
File: Fail_reads
Kinnex: '-'
_dummy: 'FailCStats'
_headings:
- Barcode
- File
- Kinnex
- Dummy
- Barcode: foo
File: Hifi_reads
Kinnex: '-'
_dummy: 'HifiCStats'
_headings:
- Barcode
- File
- Kinnex
- Dummy
_filename: m84140_240116_163605_s1.hifi_reads.all.consensusreadset.xml
_parts:
Expand Down
18 changes: 12 additions & 6 deletions test/test_compile_bc_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@
import logging
import yaml

from unittest.mock import Mock
from unittest.mock import NonCallableMock
from io import StringIO

DATA_DIR = os.path.abspath(os.path.dirname(__file__) + '/revio_out_examples')
VERBOSE = os.environ.get('VERBOSE', '0') != '0'

from compile_bc_info import gen_info

class NoneMock(NonCallableMock):
"""A Mock where fetching undefined attributes returns None,
rather then a new Mock object. Useful for mocking command
line args.
"""
def _get_child_mock(self, **kw):
return None

class T(unittest.TestCase):

@classmethod
Expand All @@ -34,16 +42,14 @@ def tearDown(self):

### THE TESTS ###
def get_mock_args(self):
args = Mock()
args = NoneMock()

args.xmlfile = None
args.metaxml = None
args.plots = []
args.stats = []
args.taxon = None
args.binning = None
args.debug = False

# For all other attributes, NoneMock returns None

return args

def test_revio_nobc(self):
Expand Down
4 changes: 4 additions & 0 deletions test/test_make_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def test_format_cell(self):
Again, test with minimal input for now.
"""
expected = dd("""\
## Basics
<dl class="dl-horizontal">
<dt>bs_project</dt>
<dd><span style='color: Tomato;'>None</span></dd>
Expand Down Expand Up @@ -138,6 +140,8 @@ def test_format_report(self):
# SMRT cell info
## Basics
<dl class="dl-horizontal">
<dt>barcodes</dt>
<dd>bc1</dd>
Expand Down

0 comments on commit f16cc21

Please sign in to comment.