-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
203 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
"""Plugin tests for the the cytof assay plugin""" | ||
|
||
import os | ||
|
||
from copy import deepcopy | ||
|
||
from django.conf import settings | ||
|
||
from samplesheets.models import Investigation | ||
from samplesheets.rendering import SampleSheetTableBuilder, SIMPLE_LINK_TEMPLATE | ||
from samplesheets.plugins import SampleSheetAssayPluginPoint, get_backend_api | ||
from samplesheets.tests.test_views import ( | ||
SheetTemplateCreateMixin, | ||
SamplesheetsViewTestBase, | ||
) | ||
from samplesheets.views import CUBI_TPL_DICT, MISC_FILES_COLL | ||
|
||
|
||
table_builder = SampleSheetTableBuilder() | ||
|
||
|
||
# Local constants | ||
PLUGIN_NAME = 'samplesheets_assay_cytof' | ||
ASSAY_NAME = 'testassayname' | ||
PANEL_NAME = 'testpanel' | ||
REPORT_NAME = 'report.txt' | ||
FILE_NAME = 'file1.txt' | ||
FILE_NAME2 = 'file2.txt' | ||
FILE_NAME3 = 'file3.txt' | ||
|
||
|
||
class TestCytofPlugin(SheetTemplateCreateMixin, SamplesheetsViewTestBase): | ||
"""Tests for cytof assay plugin""" | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.make_sheets_from_cubi_tpl(CUBI_TPL_DICT['mass_cytometry']) | ||
self.investigation = Investigation.objects.get(project=self.project) | ||
self.study = self.investigation.studies.first() | ||
self.assay = self.study.assays.first() | ||
self.study_tables = table_builder.build_study_tables(self.study) | ||
self.assay_table = self.study_tables['assays'][ | ||
str(self.assay.sodar_uuid) | ||
] | ||
self.irods_backend = get_backend_api('omics_irods') | ||
self.assay_path = self.irods_backend.get_path(self.assay) | ||
self.base_url = settings.IRODS_WEBDAV_URL + self.assay_path | ||
self.plugin = SampleSheetAssayPluginPoint.get_plugin(PLUGIN_NAME) | ||
|
||
def test_get_row_path_filled(self): | ||
"""Test get_row_path() with filled out assay name""" | ||
self.assay_table['table_data'][0][20]['value'] = ASSAY_NAME | ||
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, ASSAY_NAME) | ||
self.assertEqual(row_path, expected) | ||
|
||
def test_get_row_path_default(self): | ||
"""Test get_row_path() with default template values""" | ||
# NOTE: Assay name is not filled by default, so we return None | ||
row_path = self.plugin.get_row_path( | ||
self.assay_table['table_data'][0], | ||
self.assay_table, | ||
self.assay, | ||
self.assay_path, | ||
) | ||
self.assertEqual(row_path, None) | ||
|
||
def test_update_row_filled_panel(self): | ||
"""Test update_row() with filled panel name""" | ||
# Update unset values | ||
self.assay_table['table_data'][0][15]['value'] = PANEL_NAME | ||
self.assay_table['table_data'][0][20]['value'] = ASSAY_NAME | ||
self.assay_table['table_data'][0][26]['value'] = FILE_NAME | ||
self.assay_table['table_data'][0][31]['value'] = FILE_NAME2 | ||
self.assay_table['table_data'][0][36]['value'] = FILE_NAME3 | ||
# Set expected data | ||
row_ex = deepcopy(self.assay_table['table_data'][0]) | ||
row_ex[15]['value'] = SIMPLE_LINK_TEMPLATE.format( | ||
label=PANEL_NAME, | ||
url=os.path.join(self.base_url, MISC_FILES_COLL, PANEL_NAME), | ||
) | ||
row_ex[26]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME) | ||
row_ex[31]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME2) | ||
row_ex[36]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME3) | ||
row = self.plugin.update_row( | ||
self.assay_table['table_data'][0], self.assay_table, self.assay, 0 | ||
) | ||
self.assertEqual(row, row_ex) | ||
|
||
def test_update_row_filled_report(self): | ||
"""Test update_row() with filled report file""" | ||
self.assay_table['table_data'][0][16]['value'] = REPORT_NAME | ||
self.assay_table['table_data'][0][20]['value'] = ASSAY_NAME | ||
self.assay_table['table_data'][0][26]['value'] = FILE_NAME | ||
self.assay_table['table_data'][0][31]['value'] = FILE_NAME2 | ||
self.assay_table['table_data'][0][36]['value'] = FILE_NAME3 | ||
row_ex = deepcopy(self.assay_table['table_data'][0]) | ||
row_ex[16]['value'] = SIMPLE_LINK_TEMPLATE.format( | ||
label=REPORT_NAME, | ||
url=os.path.join(self.base_url, ASSAY_NAME, REPORT_NAME), | ||
) | ||
row_ex[26]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME) | ||
row_ex[31]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME2) | ||
row_ex[36]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME3) | ||
row = self.plugin.update_row( | ||
self.assay_table['table_data'][0], self.assay_table, self.assay, 0 | ||
) | ||
self.assertEqual(row, row_ex) | ||
|
||
def test_update_row_filled_barcode(self): | ||
"""Test update_row() with filled barcode key""" | ||
# Rename header | ||
self.assay_table['field_header'][15]['value'] = 'Barcode Key' | ||
self.assay_table['table_data'][0][15]['value'] = PANEL_NAME | ||
self.assay_table['table_data'][0][20]['value'] = ASSAY_NAME | ||
self.assay_table['table_data'][0][26]['value'] = FILE_NAME | ||
self.assay_table['table_data'][0][31]['value'] = FILE_NAME2 | ||
self.assay_table['table_data'][0][36]['value'] = FILE_NAME3 | ||
row_ex = deepcopy(self.assay_table['table_data'][0]) | ||
row_ex[15]['value'] = SIMPLE_LINK_TEMPLATE.format( | ||
label=PANEL_NAME, | ||
url=os.path.join(self.base_url, MISC_FILES_COLL, PANEL_NAME), | ||
) | ||
row_ex[26]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME) | ||
row_ex[31]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME2) | ||
row_ex[36]['link'] = os.path.join(self.base_url, ASSAY_NAME, FILE_NAME3) | ||
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_update_row_default(self): | ||
"""Test update_row() with default template values""" | ||
row_ex = deepcopy(self.assay_table['table_data'][0]) | ||
row = self.plugin.update_row( | ||
self.assay_table['table_data'][0], self.assay_table, self.assay, 0 | ||
) | ||
self.assertEqual(row, row_ex) |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters