-
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.
add dna_sequencing tests, refactor (#1980)
- Loading branch information
Showing
5 changed files
with
94 additions
and
29 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.
50 changes: 50 additions & 0 deletions
50
samplesheets/assayapps/dna_sequencing/tests/test_plugins.py
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,50 @@ | ||
"""Plugin tests for the the dna_sequencing assay plugin""" | ||
|
||
import os | ||
|
||
from copy import deepcopy | ||
|
||
from samplesheets.assayapps.tests.base import AssayPluginTestBase | ||
|
||
|
||
# Local constants | ||
MATERIAL_NAME = 'alpha' | ||
MATERIAL_NAME_UPDATE = 'alpha-material-update' | ||
|
||
|
||
class TestDNASequencingAssayPlugin(AssayPluginTestBase): | ||
"""Tests for dna_sequencing assay plugin""" | ||
|
||
plugin_name = 'samplesheets_assay_dna_sequencing' | ||
template_name = 'generic' | ||
|
||
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, MATERIAL_NAME) | ||
self.assertEqual(row_path, expected) | ||
|
||
def test_get_row_path_rename(self): | ||
"""Test get_row_path() with renamed material name""" | ||
self.assay_table['table_data'][0][-1]['value'] = MATERIAL_NAME_UPDATE | ||
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, MATERIAL_NAME_UPDATE) | ||
self.assertEqual(row_path, expected) | ||
|
||
def test_update_row(self): | ||
"""Test update_row()""" | ||
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.
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,38 @@ | ||
"""Base classes and helpers for assay plugin tests""" | ||
|
||
from django.conf import settings | ||
|
||
from samplesheets.models import Investigation | ||
from samplesheets.rendering import SampleSheetTableBuilder | ||
from samplesheets.plugins import SampleSheetAssayPluginPoint, get_backend_api | ||
from samplesheets.tests.test_views import ( | ||
SheetTemplateCreateMixin, | ||
SamplesheetsViewTestBase, | ||
) | ||
from samplesheets.views import CUBI_TPL_DICT | ||
|
||
|
||
table_builder = SampleSheetTableBuilder() | ||
|
||
|
||
class AssayPluginTestBase(SheetTemplateCreateMixin, SamplesheetsViewTestBase): | ||
"""Base test class for assay plugins""" | ||
|
||
plugin_name = None | ||
template_name = None | ||
|
||
def setUp(self): | ||
super().setUp() | ||
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_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(self.plugin_name) |