Skip to content

Commit

Permalink
add meta_ms tests (#1980)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Sep 26, 2024
1 parent a33000f commit b652e24
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
Empty file.
1 change: 0 additions & 1 deletion samplesheets/assayapps/generic_raw/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def update_row(self, row, table, assay, index):
row[i]['link'] = (
base_url + '/' + RAW_DATA_COLL + '/' + row[i]['value']
)

return row

def get_shortcuts(self, assay):
Expand Down
Empty file.
66 changes: 66 additions & 0 deletions samplesheets/assayapps/meta_ms/tests/test_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Plugin tests for the the meta_ms assay plugin"""

import os

from copy import deepcopy

from samplesheets.assayapps.tests.base import AssayPluginTestBase
from samplesheets.rendering import SIMPLE_LINK_TEMPLATE
from samplesheets.views import MISC_FILES_COLL, RESULTS_COLL


# Local constants
RAW_DATA_COLL = 'RawData'
REPORT_NAME = 'report.txt'
FILE_NAME = 'file1.txt'
FILE_NAME2 = 'file2.txt'


class TestMetaMSAssayPlugin(AssayPluginTestBase):
"""Tests for meta_ms assay plugin"""

plugin_name = 'samplesheets_assay_meta_ms'
template_name = 'ms_meta_biocrates'

def test_get_row_path(self):
"""Test get_row_path()"""
row_path = self.plugin.get_row_path(
self.assay_table['table_data'][0],
self.assay_table,
self.assay,
self.assay_path,
)
expected = os.path.join(self.assay_path, RAW_DATA_COLL)
self.assertEqual(row_path, expected)

def test_update_row(self):
"""Test update_row()"""
self.assay_table['table_data'][0][44]['value'] = FILE_NAME
self.assay_table['table_data'][0][51]['value'] = FILE_NAME2
self.assay_table['table_data'][0][55]['value'] = REPORT_NAME
row_ex = deepcopy(self.assay_table['table_data'][0])
row_ex[44]['link'] = os.path.join(
self.base_url, RAW_DATA_COLL, FILE_NAME
)
row_ex[51]['link'] = os.path.join(
self.base_url, MISC_FILES_COLL, FILE_NAME2
)
row_ex[55]['value'] = SIMPLE_LINK_TEMPLATE.format(
label=REPORT_NAME,
url=os.path.join(self.base_url, RESULTS_COLL, REPORT_NAME),
)
row = self.plugin.update_row(
self.assay_table['table_data'][0], self.assay_table, self.assay, 0
)
self.assertEqual(row, row_ex)

# TODO: Test with empty file names after fixing #2017

def test_get_shortcuts(self):
"""Test get_shortcuts()"""
expected = {
'id': 'raw_data',
'label': 'Raw Data',
'path': os.path.join(self.assay_path, RAW_DATA_COLL),
}
self.assertEqual(self.plugin.get_shortcuts(self.assay), [expected])
4 changes: 2 additions & 2 deletions samplesheets/assayapps/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def setUp(self):
self.make_sheets_from_cubi_tpl(CUBI_TPL_DICT[self.template_name])
self.investigation = Investigation.objects.get(project=self.project)
# NOTE: This assumes one study and assay, extend setup() to add more
self.study = self.investigation.studies.first()
self.assay = self.study.assays.first()
self.study = self.investigation.studies.order_by('pk').first()
self.assay = self.study.assays.order_by('pk').first()
self.study_tables = table_builder.build_study_tables(self.study)
self.assay_table = self.study_tables['assays'][
str(self.assay.sodar_uuid)
Expand Down

0 comments on commit b652e24

Please sign in to comment.