Skip to content

Commit

Permalink
upgrade to django-sodar-core v0.13.0 (wip) (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed May 10, 2023
1 parent d30fd18 commit c7d791b
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 84 deletions.
6 changes: 6 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
]
THIRD_PARTY_APPS = [
'crispy_forms', # Form layouts
'crispy_bootstrap4', # Bootstrap4 theme for Crispy
'rules.apps.AutodiscoverRulesConfig', # Django rules engine
'djangoplugins', # Django plugins
'pagedown', # For markdown
Expand Down Expand Up @@ -212,6 +213,7 @@
'projectroles.context_processors.urls_processor',
'projectroles.context_processors.site_app_processor',
'projectroles.context_processors.app_alerts_processor',
'projectroles.context_processors.sidebar_processor',
],
},
}
Expand Down Expand Up @@ -613,6 +615,10 @@ def set_logging(level=None):

# Projectroles app settings
PROJECTROLES_SITE_MODE = env.str('PROJECTROLES_SITE_MODE', 'SOURCE')
PROJECTROLES_TEMPLATE_INCLUDE_PATH = env.path(
'PROJECTROLES_TEMPLATE_INCLUDE_PATH',
os.path.join(APPS_DIR, 'templates', 'include'),
)
PROJECTROLES_SECRET_LENGTH = env.int('PROJECTROLES_SECRET_LENGTH', 32)
PROJECTROLES_INVITE_EXPIRY_DAYS = env.int('PROJECTROLES_INVITE_EXPIRY_DAYS', 14)
PROJECTROLES_SEND_EMAIL = env.bool('PROJECTROLES_SEND_EMAIL', False)
Expand Down
20 changes: 14 additions & 6 deletions irodsadmin/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

# Projectroles dependency
from projectroles.constants import SODAR_CONSTANTS
from projectroles.models import Role
from projectroles.plugins import get_backend_api
from projectroles.tests.test_models import ProjectMixin, RoleAssignmentMixin
from projectroles.tests.test_models import (
ProjectMixin,
RoleMixin,
RoleAssignmentMixin,
)

# Landingzones dependency
from landingzones.tests.test_models import LandingZoneMixin
Expand All @@ -25,6 +28,7 @@

# SODAR constants
PROJECT_ROLE_OWNER = SODAR_CONSTANTS['PROJECT_ROLE_OWNER']
PROJECT_TYPE_CATEGORY = SODAR_CONSTANTS['PROJECT_TYPE_CATEGORY']
PROJECT_TYPE_PROJECT = SODAR_CONSTANTS['PROJECT_TYPE_PROJECT']

# Local constants
Expand All @@ -34,10 +38,11 @@


class TestIrodsOrphans(
ProjectMixin,
SampleSheetIOMixin,
RoleAssignmentMixin,
LandingZoneMixin,
RoleAssignmentMixin,
ProjectMixin,
RoleMixin,
TestCase,
):
"""Tests for the irodsorphans management command"""
Expand All @@ -50,10 +55,13 @@ def setUp(self):
self.user.is_staff = True
self.user.save()
# Init roles
self.role_owner = Role.objects.get_or_create(name=PROJECT_ROLE_OWNER)[0]
self.init_roles()
# Init category with owner
# Init project with owner
self.project = self.make_project(
'TestProject', PROJECT_TYPE_PROJECT, None
'TestProject',
PROJECT_TYPE_PROJECT,
None,
)
self.owner_as = self.make_assignment(
self.project, self.user, self.role_owner
Expand Down
53 changes: 24 additions & 29 deletions irodsbackend/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
from test_plus.test import TestCase

# Projectroles dependency
from projectroles.models import Role, SODAR_CONSTANTS
from projectroles.tests.test_models import ProjectMixin, RoleAssignmentMixin
from projectroles.models import SODAR_CONSTANTS
from projectroles.tests.test_models import (
ProjectMixin,
RoleMixin,
RoleAssignmentMixin,
)

# Samplesheets dependency
from samplesheets.tests.test_io import SampleSheetIOMixin, SHEET_DIR
Expand Down Expand Up @@ -47,10 +51,11 @@


class TestIrodsbackendAPI(
ProjectMixin,
RoleAssignmentMixin,
SampleSheetIOMixin,
LandingZoneMixin,
ProjectMixin,
RoleMixin,
RoleAssignmentMixin,
TestCase,
):
"""Tests for the API in the irodsbackend app"""
Expand All @@ -60,27 +65,18 @@ def setUp(self):
self.user = self.make_user('user')
self.user.save()
# Init roles
self.role_owner = Role.objects.get_or_create(name=PROJECT_ROLE_OWNER)[0]
self.role_delegate = Role.objects.get_or_create(
name=PROJECT_ROLE_DELEGATE
)[0]
self.role_contributor = Role.objects.get_or_create(
name=PROJECT_ROLE_CONTRIBUTOR
)[0]
self.role_guest = Role.objects.get_or_create(name=PROJECT_ROLE_GUEST)[0]
self.init_roles()
# Init project with owner
self.project = self.make_project(
'TestProject', PROJECT_TYPE_PROJECT, None
)
self.owner_as = self.make_assignment(
self.project, self.user, self.role_owner
)

# Import investigation
self.investigation = self.import_isa_from_file(SHEET_PATH, self.project)
self.study = self.investigation.studies.first()
self.assay = self.study.assays.first()

# Create LandingZone
self.landing_zone = self.make_landing_zone(
title=ZONE_TITLE,
Expand All @@ -91,7 +87,6 @@ def setUp(self):
configuration=None,
config_data={},
)

self.irods_backend = IrodsAPI()

def test_format_env(self):
Expand Down Expand Up @@ -137,7 +132,7 @@ def test_sanitize_path(self):
self.assertEqual(ex, ERROR_PATH_PARENT)

def test_get_path_project(self):
"""Test get_irods_path() with a Project object"""
"""Test get_irods_path() with Project object"""
expected = '/{zone}/projects/{uuid_prefix}/{uuid}'.format(
zone=IRODS_ZONE,
uuid_prefix=str(self.project.sodar_uuid)[:2],
Expand All @@ -148,7 +143,7 @@ def test_get_path_project(self):

@override_settings(IRODS_ROOT_PATH=IRODS_ROOT_PATH)
def test_get_path_project_root_path(self):
"""Test get_irods_path() with a Project object and root path"""
"""Test get_irods_path() with Project object and root path"""
expected = '/{zone}/projects/{root_path}/{uuid_prefix}/{uuid}'.format(
zone=IRODS_ZONE,
root_path=IRODS_ROOT_PATH,
Expand All @@ -159,7 +154,7 @@ def test_get_path_project_root_path(self):
self.assertEqual(expected, path)

def test_get_path_study(self):
"""Test get_irods_path() with a Study object"""
"""Test get_irods_path() with Study object"""
expected = (
'/{zone}/projects/{uuid_prefix}/{uuid}/{sample_coll}'
'/{study}'.format(
Expand All @@ -174,7 +169,7 @@ def test_get_path_study(self):
self.assertEqual(expected, path)

def test_get_path_assay(self):
"""Test get_irods_path() with an Assay object"""
"""Test get_irods_path() with Assay object"""
expected = (
'/{zone}/projects/{uuid_prefix}/{uuid}/{sample_coll}'
'/{study}/{assay}'.format(
Expand All @@ -190,7 +185,7 @@ def test_get_path_assay(self):
self.assertEqual(expected, path)

def test_get_path_zone(self):
"""Test get_irods_path() with a LandingZone object"""
"""Test get_irods_path() with LandingZone object"""
expected = (
'/{zone}/projects/{uuid_prefix}/{uuid}/{zone_dir}'
'/{user}/{study_assay}/{zone_title}'.format(
Expand All @@ -209,7 +204,7 @@ def test_get_path_zone(self):
self.assertEqual(expected, path)

def test_get_sample_path(self):
"""Test get_sample_path() with a Project object"""
"""Test get_sample_path() with Project object"""
expected = '/{zone}/projects/{uuid_prefix}/{uuid}/{sample_coll}'.format(
zone=IRODS_ZONE,
uuid_prefix=str(self.project.sodar_uuid)[:2],
Expand All @@ -220,7 +215,7 @@ def test_get_sample_path(self):
self.assertEqual(expected, path)

def test_get_sample_path_no_project(self):
"""Test get_sample_path() with a wrong type of object (should fail)"""
"""Test get_sample_path() with wrong object type (should fail)"""
with self.assertRaises(ValueError):
self.irods_backend.get_sample_path(self.study)

Expand All @@ -247,26 +242,26 @@ def test_get_projects_path_with_root_path(self):
self.assertEqual(self.irods_backend.get_projects_path(), expected)

def test_get_uuid_from_path_assay(self):
"""Test get_uuid_from_path() with an assay path"""
"""Test get_uuid_from_path() with assay path"""
path = self.irods_backend.get_path(self.assay)
uuid = self.irods_backend.get_uuid_from_path(path, 'assay')
self.assertEqual(uuid, str(self.assay.sodar_uuid))

def test_get_uuid_from_path_project(self):
"""Test get_uuid_from_path() for project UUID with an assay path"""
"""Test get_uuid_from_path() for project UUID with assay path"""
path = self.irods_backend.get_path(self.assay)
uuid = self.irods_backend.get_uuid_from_path(path, 'project')
self.assertEqual(uuid, str(self.project.sodar_uuid))

def test_get_uuid_from_path_wrong_type(self):
"""Test get_uuid_from_path() with an invalid type (should fail)"""
"""Test get_uuid_from_path() with invalid type (should fail)"""
path = self.irods_backend.get_path(self.study)

with self.assertRaises(ValueError):
self.irods_backend.get_uuid_from_path(path, 'investigation')

def test_get_uuid_from_path_wrong_path(self):
"""Test get_uuid_from_path() with a path not containing the uuid (should fail)"""
"""Test get_uuid_from_path() on path without uuid (should fail)"""
path = self.irods_backend.get_path(self.project)
uuid = self.irods_backend.get_uuid_from_path(path, 'study')
self.assertIsNone(uuid)
Expand All @@ -279,21 +274,21 @@ def test_get_uuid_from_path_root_path(self):
self.assertEqual(uuid, str(self.assay.sodar_uuid))

def test_get_user_group_name(self):
"""Test get_user_group_name() with a Project object"""
"""Test get_user_group_name() with Project object"""
self.assertEqual(
self.irods_backend.get_user_group_name(self.project),
'{}{}'.format(USER_GROUP_PREFIX, self.project.sodar_uuid),
)

def test_get_user_group_name_uuid(self):
"""Test get_user_group_name() with an UUID object"""
"""Test get_user_group_name() with UUID object"""
self.assertEqual(
self.irods_backend.get_user_group_name(self.project.sodar_uuid),
'{}{}'.format(USER_GROUP_PREFIX, self.project.sodar_uuid),
)

def test_get_user_group_name_uuid_str(self):
"""Test get_user_group_name() with an UUID string"""
"""Test get_user_group_name() with UUID string"""
self.assertEqual(
self.irods_backend.get_user_group_name(
str(self.project.sodar_uuid)
Expand Down
2 changes: 1 addition & 1 deletion landingzones/tasks_taskflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def set_status(cls, zone, flow_name, status, status_info, extra_data=None):
set(
[
r.user
for r in zone.project.get_all_roles()
for r in zone.project.get_roles()
if r.user != zone.user
]
)
Expand Down
1 change: 0 additions & 1 deletion landingzones/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _assert_btn_enabled(self, element, expected=True):
def setUp(self):
super().setUp()
# NOTE: Temp inherited owner override, see bihealth/sodar-core#1103
self.user_owner_cat = self.make_user('user_owner_cat')
self.owner_as_cat = RoleAssignment.objects.get(
project=self.category, role=self.role_owner
)
Expand Down
35 changes: 18 additions & 17 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
# Wheel
# NOTE: For best results wheel should be installed separately before other deps
wheel==0.38.4
wheel==0.40.0

# Setuptools
setuptools==65.6.3
setuptools==67.6.0

# Django
django==3.2.19
django>=3.2.18, <3.3

# Configuration
django-environ==0.9.0
django-environ==0.10.0

# Forms
django-crispy-forms==1.14.0
django-crispy-forms==2.0
crispy-bootstrap4==2022.1

# Models
django-model-utils==4.2.0
django-model-utils==4.3.1

# Password storage
argon2-cffi==21.3.0

# Python-PostgreSQL Database Adapter
psycopg2-binary==2.9.3
psycopg2-binary==2.9.5

# Unicode slugification
awesome-slugify==1.6.5

# Time zones support
pytz==2022.2.1
pytz==2022.7.1

# Redis support
redis>=4.5.4, <4.6
Expand All @@ -36,13 +37,13 @@ redis>=4.5.4, <4.6
django-cprofile-middleware==1.0.5

# Versioning
versioneer==0.23
versioneer==0.28

# Online documentation via django-docs
docutils==0.17.1
Sphinx==5.1.1
django-docs==0.3.1
sphinx-rtd-theme==1.0.0
docutils==0.18.1
Sphinx==6.1.3
django-docs==0.3.3
sphinx-rtd-theme==1.2.0
sphinxcontrib-youtube==1.2.0

#####################
Expand All @@ -53,7 +54,7 @@ sphinxcontrib-youtube==1.2.0
rules==3.3

# REST framework
djangorestframework==3.13.1
djangorestframework==3.14.0

# Keyed list addon for DRF
# drf-keyed-list==0.0.2
Expand All @@ -66,14 +67,14 @@ django-rest-knox==4.2.0
markdown==3.4.1
django-markupfield==2.0.1
django-pagedown==2.2.1
mistune==2.0.4
mistune==2.0.5

# Django-plugins (with Django v3.0+ support)
-e git+https://github.com/mikkonie/django-plugins.git@42e86e7904e5c09f1da32173862b26843eda5dd8#egg=django-plugins

# SODAR Core
django-sodar-core==0.12.0
# -e git+https://github.com/bihealth/sodar-core.git@55d46268e5da4ef8a26913ce3b2c584d794d275c#egg=django-sodar-core
# django-sodar-core==0.12.0
-e git+https://github.com/bihealth/sodar-core.git@09881c342243e14abcc7c84ee3758d20cf8a41cf#egg=django-sodar-core

# Celery
celery==5.2.7
Expand Down
2 changes: 1 addition & 1 deletion requirements/ldap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
-r base.txt

django-auth-ldap==4.1.0
python-ldap==3.4.2
python-ldap==3.4.3
6 changes: 3 additions & 3 deletions requirements/local.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Local development dependencies go here
-r base.txt

django-extensions==3.2.0
django-extensions==3.2.1
Werkzeug==2.2.3
django-debug-toolbar==3.6.0
django-debug-toolbar==3.8.1

# improved REPL
ipdb==0.13.9
ipdb==0.13.13
Loading

0 comments on commit c7d791b

Please sign in to comment.