Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: "poetry"
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: "poetry"
Expand All @@ -67,10 +67,15 @@ jobs:
cd server
poetry install --with dev

- name: Server-Side Linting
# - name: Run Ruff check
# run: |
# cd server
# poetry run ruff check --output-format=github .

- name: Run Ruff format check
run: |
cd server
poetry run flake8
poetry run ruff format --check .

Client_Side_Unit_Tests:
runs-on: ubuntu-24.04
Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.5
hooks:
# - id: ruff-check
# args: [--fix]
# files: ^server/
- id: ruff-format
files: ^server/
172 changes: 109 additions & 63 deletions README.md

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions server/.flake8

This file was deleted.

6 changes: 6 additions & 0 deletions server/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pre-commit"
directory: "/"
schedule:
interval: "weekly"
40 changes: 20 additions & 20 deletions server/conf/cms/secrets.sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@
# DJANGO SETTINGS
########################

SECRET_KEY = 'replacethiswithareallysecureandcomplexsecretkeystring'
LOGIN_REDIRECT_URL = '/workbench/dashboard/'
SECRET_KEY = "replacethiswithareallysecureandcomplexsecretkeystring"
LOGIN_REDIRECT_URL = "/workbench/dashboard/"

########################
# ELASTICSEARCH
########################

ES_AUTH = 'username:password'
ES_HOSTS = 'http://elasticsearch:9200'
ES_INDEX_PREFIX = 'cep-dev-{}'
ES_DOMAIN = 'https://cep.test'
ES_AUTH = "username:password"
ES_HOSTS = "http://elasticsearch:9200"
ES_INDEX_PREFIX = "cep-dev-{}"
ES_DOMAIN = "https://cep.test"

es_engine = 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine'
es_engine = "haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine"
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': es_engine,
'URL': ES_HOSTS,
'INDEX_NAME': ES_INDEX_PREFIX.format('cms'),
'KWARGS': {'http_auth': ES_AUTH}
"default": {
"ENGINE": es_engine,
"URL": ES_HOSTS,
"INDEX_NAME": ES_INDEX_PREFIX.format("cms"),
"KWARGS": {"http_auth": ES_AUTH},
}
}

########################
# RECAPTCHA SETTINGS
########################

RECAPTCHA_PUBLIC_KEY = ''
RECAPTCHA_PRIVATE_KEY = ''
SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']
RECAPTCHA_PUBLIC_KEY = ""
RECAPTCHA_PRIVATE_KEY = ""
SILENCED_SYSTEM_CHECKS = ["captcha.recaptcha_test_key_error"]

########################
# REDMINE TRACKER AUTH
########################

RT_HOST = ''
RT_UN = ''
RT_PW = ''
RT_QUEUE = ''
RT_TAG = ''
RT_HOST = ""
RT_UN = ""
RT_PW = ""
RT_QUEUE = ""
RT_TAG = ""
84 changes: 37 additions & 47 deletions server/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@pytest.fixture
def mock_tapis_client(mocker):
yield mocker.patch('portal.apps.auth.models.TapisOAuthToken.client', autospec=True)
yield mocker.patch("portal.apps.auth.models.TapisOAuthToken.client", autospec=True)


@pytest.fixture
Expand All @@ -20,54 +20,47 @@ def mock_googledrive_client(mocker):

@pytest.fixture
def regular_user(django_user_model, django_db_reset_sequences, mock_tapis_client):
django_user_model.objects.create_user(username="username",
password="password",
first_name="Firstname",
last_name="Lastname",
email="user@user.com")
django_user_model.objects.create_user(
username="username", password="password", first_name="Firstname", last_name="Lastname", email="user@user.com"
)
user = django_user_model.objects.get(username="username")
TapisOAuthToken.objects.create(
user=user,
access_token="1234fsf",
refresh_token="123123123",
expires_in=14400,
created=1523633447)
user=user, access_token="1234fsf", refresh_token="123123123", expires_in=14400, created=1523633447
)
PortalProfile.objects.create(user=user)
yield user


@pytest.fixture
def regular_user2(django_user_model, django_db_reset_sequences, mock_tapis_client):
django_user_model.objects.create_user(username="username2",
password="password",
first_name="Firstname2",
last_name="Lastname2",
email="user2@user.com")
django_user_model.objects.create_user(
username="username2",
password="password",
first_name="Firstname2",
last_name="Lastname2",
email="user2@user.com",
)
user = django_user_model.objects.get(username="username2")
TapisOAuthToken.objects.create(
user=user,
access_token="1234fsf",
refresh_token="123123123",
expires_in=14400,
created=1523633447)
user=user, access_token="1234fsf", refresh_token="123123123", expires_in=14400, created=1523633447
)
PortalProfile.objects.create(user=user)
yield user


@pytest.fixture
def regular_user_with_underscore(django_user_model, django_db_reset_sequences, mock_tapis_client):
django_user_model.objects.create_user(username="user_name",
password="password",
first_name="Firstname3",
last_name="Lastname3",
email="user_name@user.com")
django_user_model.objects.create_user(
username="user_name",
password="password",
first_name="Firstname3",
last_name="Lastname3",
email="user_name@user.com",
)
user = django_user_model.objects.get(username="user_name")
TapisOAuthToken.objects.create(
user=user,
access_token="1234fsf",
refresh_token="123123123",
expires_in=14400,
created=1523633447)
user=user, access_token="1234fsf", refresh_token="123123123", expires_in=14400, created=1523633447
)
PortalProfile.objects.create(user=user)
yield user

Expand All @@ -80,16 +73,13 @@ def authenticated_user(client, regular_user):

@pytest.fixture
def staff_user(client, django_user_model, django_db_reset_sequences, mock_tapis_client):
django_user_model.objects.create_user(username='staff', password='password')
user = django_user_model.objects.get(username='staff')
django_user_model.objects.create_user(username="staff", password="password")
user = django_user_model.objects.get(username="staff")
user.is_staff = True
user.save()
TapisOAuthToken.objects.create(
user=user,
access_token="1234fsf",
refresh_token="123123123",
expires_in=14400,
created=1523633447)
user=user, access_token="1234fsf", refresh_token="123123123", expires_in=14400, created=1523633447
)
PortalProfile.objects.create(user=user)
yield user

Expand All @@ -102,47 +92,47 @@ def authenticated_staff(client, staff_user):

@pytest.fixture
def tapis_indexer(mocker):
yield mocker.patch('portal.libs.agave.operations.tapis_indexer')
yield mocker.patch("portal.libs.agave.operations.tapis_indexer")


@pytest.fixture
def tapis_listing_indexer(mocker):
yield mocker.patch('portal.libs.agave.operations.tapis_listing_indexer')
yield mocker.patch("portal.libs.agave.operations.tapis_listing_indexer")


@pytest.fixture
def agave_storage_system_mock():
with open(os.path.join(settings.BASE_DIR, 'fixtures/agave/systems/storage.json')) as f:
with open(os.path.join(settings.BASE_DIR, "fixtures/agave/systems/storage.json")) as f:
yield json.load(f)


@pytest.fixture
def tapis_file_mock():
with open(os.path.join(settings.BASE_DIR, 'fixtures/agave/files/file.json')) as f:
with open(os.path.join(settings.BASE_DIR, "fixtures/agave/files/file.json")) as f:
yield json.load(f)


@pytest.fixture
def agave_file_listing_mock():
with open(os.path.join(settings.BASE_DIR, 'fixtures/agave/files/file-listing.json')) as f:
with open(os.path.join(settings.BASE_DIR, "fixtures/agave/files/file-listing.json")) as f:
yield json.load(f)


@pytest.fixture
def tapis_file_listing_mock():
with open(os.path.join(settings.BASE_DIR, 'fixtures/agave/files/tapis-file-listing.json')) as f:
with open(os.path.join(settings.BASE_DIR, "fixtures/agave/files/tapis-file-listing.json")) as f:
yield json.load(f)


@pytest.fixture
def agave_listing_mock():
with open(os.path.join(settings.BASE_DIR, 'fixtures/agave/files/listing.json')) as f:
with open(os.path.join(settings.BASE_DIR, "fixtures/agave/files/listing.json")) as f:
yield json.load(f)


@pytest.fixture
def tapis_tokens_create_mock():
yield json.load(open(os.path.join(settings.BASE_DIR, 'fixtures/agave/auth/create-tokens-response.json')))
yield json.load(open(os.path.join(settings.BASE_DIR, "fixtures/agave/auth/create-tokens-response.json")))


@pytest.fixture
Expand All @@ -151,5 +141,5 @@ def text_file_fixture():
filename = os.path.join(temp_directory, "text_file.txt")
with open(filename, "w") as text_file:
text_file.write("this is the contents of my text file")
with open(filename, 'rb') as text_file:
with open(filename, "rb") as text_file:
yield text_file
5 changes: 3 additions & 2 deletions server/manage.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'portal.settings.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "portal.settings.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand All @@ -17,5 +18,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading
Loading