Skip to content

Commit

Permalink
fix: don't assume upload has all data
Browse files Browse the repository at this point in the history
  • Loading branch information
Xarthisius committed Oct 27, 2023
1 parent 40aae22 commit 3b09cae
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 72 deletions.
54 changes: 4 additions & 50 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,18 @@ envlist = lint,pytest
deps =
-rrequirements-dev.txt
commands =
pytest --cov=virtual_resources --cov-report=xml {posargs}
pytest {posargs}

[testenv:lint]
skip_install = true
skipdist = true
deps =
flake8
flake8-bugbear
flake8-comprehensions
flake8-docstrings
flake8-import-order
pep8-naming
ruff
commands =
flake8 {posargs}

[flake8]
max-line-length = 100
show-source = True
max-complexity = 14
format = pylint
exclude =
node_modules,
.eggs,
.git,
__pycache__,
.tox
ignore =
# D10 - Missing docstring (errors D100 - D107)
D10,
# D200 - One-line docstrings should fit on one line with quotes.
D200,
# D205 - Blank line required between one-line summary and description.
D205,
# D400 - First line should end with a period.
D400,
# D401 - First line should be in imperative mood.
D401,
# E123 - Closing bracket does not match indentation of opening bracket's line
E123,
# N802 - Function name should be lowercase.
N802,
# N803 - Argument name should be lowercase.
N803,
# N806 - Variable in function should be lowercase.
N806,
# N812 - Lowercase imported as non lowercase.
N812,
# N815 - mixedCase variable in class scope
N815,
# N816 - mixedCase variable in global scope
N816,
# N818 - error suffix in exception name
N818,
# W503 - Line break occurred before a binary operator
W503,
ruff check .

[pytest]
addopts = --verbose --strict --showlocals
addopts = --verbose --strict --showlocals --cov=virtual_resources --cov-report=xml
cache_dir = build/test/pytest_cache
junit_family = xunit2
testpaths = test
4 changes: 2 additions & 2 deletions virtual_resources/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def wrapper(self, event):

if "uploadId" in params:
upload = Upload().load(params["uploadId"])
parent_id = str(upload["parentId"])
parent_type = upload["parentType"]
parent_id = str(upload.get("parentId"))
parent_type = upload.get("parentType") or "folder"
else:
parent_id = params.get("parentId")
parent_type = params.get("parentType") or "folder"
Expand Down
8 changes: 0 additions & 8 deletions virtual_resources/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# -*- coding: utf-8 -*-

import pathlib
import random
import string

from girder.exceptions import ValidationException

Expand All @@ -15,12 +13,6 @@
chunk1, chunk2 = ("hello ", "world")


def random_string(length=10):
"""Generate a random string of fixed length."""
letters = string.ascii_lowercase
return "".join(random.choice(letters) for i in range(length))


def test_vo_methods(mapped_folder):
from virtual_resources.rest import VirtualObject

Expand Down
13 changes: 1 addition & 12 deletions virtual_resources/tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@

import os
import pathlib
import random
import shutil
import string


import pytest
from girder.models.assetstore import Assetstore
from girder.models.setting import Setting
from girder.settings import SettingKey

import pytest

from pytest_girder.assertions import assertStatus, assertStatusOk
from pytest_girder.utils import getResponseBody

Expand All @@ -22,12 +17,6 @@
chunk1, chunk2 = ("hello ", "world")


def random_string(length=10):
"""Generate a random string of fixed length."""
letters = string.ascii_lowercase
return "".join(random.choice(letters) for i in range(length))


@pytest.mark.plugin("virtual_resources")
def test_basic_file_ops(server, user, extra_user, example_mapped_folder):
mapped_folder = example_mapped_folder["girder_root"]
Expand Down

0 comments on commit 3b09cae

Please sign in to comment.