Skip to content

Commit

Permalink
cleanup (#1706)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Aug 1, 2023
1 parent 811a271 commit 624250e
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 85 deletions.
2 changes: 1 addition & 1 deletion samplesheets/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def clean(self):


class IrodsDataRequestAcceptForm(forms.Form):
"""Form for accepting an iRODS data requests"""
"""Form for accepting an iRODS data request"""

confirm = forms.BooleanField(required=True)

Expand Down
14 changes: 7 additions & 7 deletions samplesheets/tests/test_models_taskflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,32 @@ def setUp(self):
# Create iRODS collections
self.make_irods_colls(self.investigation)
self.assay_path = self.irods_backend.get_path(self.assay)
self.path_obj = os.path.join(self.assay_path, TEST_FILE_NAME)
self.path_coll = os.path.join(self.assay_path, TEST_COLL_NAME)
self.obj_path = os.path.join(self.assay_path, TEST_FILE_NAME)
self.coll_path = os.path.join(self.assay_path, TEST_COLL_NAME)
# Create objects
self.file_obj = self.irods.data_objects.create(self.path_obj)
self.coll = self.irods.collections.create(self.path_coll)
self.file_obj = self.irods.data_objects.create(self.obj_path)
self.coll = self.irods.collections.create(self.coll_path)

# Create request
self.request = self.make_irods_request(
project=self.project,
action=IRODS_REQUEST_ACTION_DELETE,
status=IRODS_REQUEST_STATUS_ACTIVE,
path=self.path_obj,
path=self.obj_path,
description=IRODS_REQUEST_DESC,
user=self.user_owner_cat,
)

def test_is_data_object(self):
"""Test is_data_object()"""
self.assertTrue(self.request.is_data_object())
self.request.path = self.path_coll
self.request.path = self.coll_path
self.request.save()
self.assertFalse(self.request.is_data_object())

def test_is_collection(self):
"""Test is_collection()"""
self.assertFalse(self.request.is_collection())
self.request.path = self.path_coll
self.request.path = self.coll_path
self.request.save()
self.assertTrue(self.request.is_collection())
30 changes: 15 additions & 15 deletions samplesheets/tests/test_permissions_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
IRODS_FILE_PATH = '/sodarZone/path/test1.txt'


class TestSampleSheetsAjaxPermissionBase(
class SampleSheetsAjaxPermissionTestBase(
SampleSheetIOMixin, TestProjectPermissionBase
):
"""Base test class for samplesheets Ajax view permissions"""
Expand All @@ -42,7 +42,7 @@ def setUp(self):
self.assay = self.study.assays.first()


class TestSheetContextAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetContextAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetContextAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_get_archive(self):
self.assert_response(self.url, self.anonymous, 403)


class TestStudyTablesAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestStudyTablesAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for StudyTablesAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_get_not_allowed_archive(self):
self.assert_response(self.url, users, 403, data=self.edit_data)


class TestStudyLinksAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestStudyLinksAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for StudyLinksAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -322,7 +322,7 @@ def test_get_archive(self):
self.assert_response(self.url, bad_users, 403)


class TestSheetWarningsAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetWarningsAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetWarningsAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -384,7 +384,7 @@ def test_get_archive(self):
self.assert_response(self.url, self.anonymous, 403)


class TestSheetCellEditAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetCellEditAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetCellEditAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -446,7 +446,7 @@ def test_post_archive(self):
self.assert_response(self.url, bad_users, 403, method='POST')


class TestSheetRowInsertAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetRowInsertAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetRowInsertAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -508,7 +508,7 @@ def test_post_archive(self):
self.assert_response(self.url, bad_users, 403, method='POST')


class TestSheetRowDeleteAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetRowDeleteAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetRowDeleteAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -570,7 +570,7 @@ def test_post_archive(self):
self.assert_response(self.url, bad_users, 403, method='POST')


class TestSheetVersionSaveAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetVersionSaveAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetVersionSaveAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -632,7 +632,7 @@ def test_post_archive(self):
self.assert_response(self.url, bad_users, 403, method='POST')


class TestSheetEditFinishAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetEditFinishAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetEditFinishAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -694,7 +694,7 @@ def test_post_archive(self):
self.assert_response(self.url, bad_users, 403, method='POST')


class TestSheetEditConfigAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetEditConfigAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetEditConfigAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -758,7 +758,7 @@ def test_post_archive(self):
self.assert_response(self.url, bad_users, 403, method='POST')


class TestStudyDisplayConfigAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestStudyDisplayConfigAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for StudyDisplayConfigAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -819,7 +819,7 @@ def test_post_archive(self):
self.assert_response(self.url, self.anonymous, 403, method='POST')


class TestSheetVersionCompareAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestSheetVersionCompareAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for SheetVersionCompareAjaxView"""

def setUp(self):
Expand Down Expand Up @@ -884,7 +884,7 @@ def test_get_archive(self):
self.assert_response(self.url, [self.anonymous], 403)


class TestIrodsDataRequestCreateAjaxView(TestSampleSheetsAjaxPermissionBase):
class TestIrodsDataRequestCreateAjaxView(SampleSheetsAjaxPermissionTestBase):
"""Permission tests for IrodsDataRequestCreateAjaxView"""

@classmethod
Expand Down Expand Up @@ -992,7 +992,7 @@ def test_post_archive(self):


class TestIrodsDataRequestDeleteAjaxView(
IrodsDataRequestMixin, TestSampleSheetsAjaxPermissionBase
IrodsDataRequestMixin, SampleSheetsAjaxPermissionTestBase
):
"""Permission tests for IrodsDataRequestDeleteAjaxView"""

Expand Down
34 changes: 17 additions & 17 deletions samplesheets/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
# TODO: Add testing for study table cache updates


class TestViewsBase(
class ViewTestBase(
ProjectMixin, RoleMixin, RoleAssignmentMixin, SampleSheetIOMixin, TestCase
):
"""Base view for samplesheets views tests"""
Expand Down Expand Up @@ -170,7 +170,7 @@ def setUp(self):
)


class TestProjectSheetsView(TestViewsBase):
class TestProjectSheetsView(ViewTestBase):
"""Tests for the project sheets view"""

def setUp(self):
Expand Down Expand Up @@ -198,7 +198,7 @@ def test_render_no_sheets(self):
self.assertNotIn('tables', response.context)


class TestSheetImportView(SheetImportMixin, LandingZoneMixin, TestViewsBase):
class TestSheetImportView(SheetImportMixin, LandingZoneMixin, ViewTestBase):
"""Tests for the investigation import view"""

def setUp(self):
Expand Down Expand Up @@ -665,7 +665,7 @@ def test_import_no_plugin_assay(self):
)


class TestSheetTemplateSelectView(TestViewsBase):
class TestSheetTemplateSelectView(ViewTestBase):
"""Tests for SheetTemplateSelectView"""

def test_render(self):
Expand Down Expand Up @@ -702,7 +702,7 @@ def test_render_with_sheets(self):
)


class TestSheetTemplateCreateFormView(TestViewsBase):
class TestSheetTemplateCreateFormView(ViewTestBase):
"""Tests for SheetTemplateCreateFormView"""

def _get_post_data(self, tpl_name):
Expand Down Expand Up @@ -819,7 +819,7 @@ def test_post_multiple(self):
self.assertEqual(self.project.investigations.count(), 1)


class TestSheetExcelExportView(TestViewsBase):
class TestSheetExcelExportView(ViewTestBase):
"""Tests for the sample sheet Excel export view"""

def setUp(self):
Expand Down Expand Up @@ -863,7 +863,7 @@ def test_render_assay(self):
self.assertEqual(tl_event.event_name, 'sheet_export_excel')


class TestSheetISAExportView(TestViewsBase):
class TestSheetISAExportView(ViewTestBase):
"""Tests for the investigation ISA-Tab export view"""

def setUp(self):
Expand Down Expand Up @@ -930,7 +930,7 @@ def test_get_version(self):
)


class TestSheetDeleteView(TestViewsBase):
class TestSheetDeleteView(ViewTestBase):
"""Tests for the investigation delete view"""

def setUp(self):
Expand Down Expand Up @@ -1056,7 +1056,7 @@ def test_delete_study_cache(self):
self.assertEqual(JSONCacheItem.objects.count(), 0)


class TestSheetVersionListView(TestViewsBase):
class TestSheetVersionListView(ViewTestBase):
"""Tests for the sample sheet version list view"""

def test_render(self):
Expand Down Expand Up @@ -1098,7 +1098,7 @@ def test_render_no_sheets(self):
self.assertIsNone(response.context['current_version'])


class TestSheetVersionRestoreView(TestViewsBase):
class TestSheetVersionRestoreView(ViewTestBase):
"""Tests for the sample sheet version restore view"""

def setUp(self):
Expand Down Expand Up @@ -1184,7 +1184,7 @@ def test_restore_study_cache(self):
self.assertEqual(JSONCacheItem.objects.count(), 1)


class TestSheetVersionUpdateView(TestViewsBase):
class TestSheetVersionUpdateView(ViewTestBase):
"""Tests for the sample sheet version update view"""

def setUp(self):
Expand Down Expand Up @@ -1229,7 +1229,7 @@ def test_update(self):
self.assertEqual(self.isatab.date_created, date_created)


class TestSheetVersionDeleteView(TestViewsBase):
class TestSheetVersionDeleteView(ViewTestBase):
"""Tests for the sample sheet version delete view"""

def setUp(self):
Expand Down Expand Up @@ -1267,7 +1267,7 @@ def test_post(self):
self.assertEqual(ISATab.objects.count(), 0)


class TestSheetVersionDeleteBatchView(SampleSheetModelMixin, TestViewsBase):
class TestSheetVersionDeleteBatchView(SampleSheetModelMixin, ViewTestBase):
"""Tests for the sample sheet version batch delete view"""

def setUp(self):
Expand Down Expand Up @@ -1334,7 +1334,7 @@ def test_delete(self):
self.assertEqual(ISATab.objects.count(), 0)


class TestProjectSearchResultsView(TestViewsBase):
class TestProjectSearchResultsView(ViewTestBase):
"""Tests for ProjectSearchResultsView view with sample sheet input"""

def _get_items(self, response):
Expand Down Expand Up @@ -1442,7 +1442,7 @@ def test_search_multi(self):
self.assertEqual(len(items), 2)


class TestSheetVersionCompareView(TestViewsBase):
class TestSheetVersionCompareView(ViewTestBase):
"""Tests for the SheetVersionCompareView"""

def setUp(self):
Expand Down Expand Up @@ -1501,7 +1501,7 @@ def test_render_no_permission(self):
self.assertRedirects(response, reverse('home'))


class TestSheetVersionCompareFileView(TestViewsBase):
class TestSheetVersionCompareFileView(ViewTestBase):
"""Tests for the SheetVersionCompareFileView"""

def setUp(self):
Expand Down Expand Up @@ -1566,7 +1566,7 @@ def test_render_no_permission(self):
self.assertRedirects(response, reverse('home'))


class TestIrodsDataRequestListView(IrodsDataRequestMixin, TestViewsBase):
class TestIrodsDataRequestListView(IrodsDataRequestMixin, ViewTestBase):
"""Tests for IrodsDataRequestListView"""

def test_list(self):
Expand Down
Loading

0 comments on commit 624250e

Please sign in to comment.