Skip to content

Commit

Permalink
Update HUMAN2BYTES_MAPPER and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Nov 16, 2023
1 parent e31c155 commit 6cc0dbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions rdmo/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
}

HUMAN2BYTES_MAPPER = {
"b": {"base": 1000, "power": 0},
"kb": {"base": 1000, "power": 1},
"k": {"base": 1000, "power": 1},
"mb": {"base": 1000, "power": 2},
Expand Down
23 changes: 22 additions & 1 deletion rdmo/projects/tests/test_validator_quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
attribute_path = attribute__path='individual/single/text'


def test_serializer_create_file(db):
def test_serializer_create_file(db, settings):
class MockedProject:
file_size = 1

class MockedView:
action = 'create'
project = MockedProject()

settings.PROJECT_FILE_QUOTA = '1b'

validator = ValueQuotaValidator()
serializer = ValueSerializer()
serializer.context['view'] = MockedView()
Expand Down Expand Up @@ -63,3 +65,22 @@ class MockedView:
validator({
'value_type': 'text'
}, serializer)


def test_serializer_update(db, settings):
class MockedProject:
file_size = 1

class MockedView:
action = 'update'
project = MockedProject()

settings.PROJECT_FILE_QUOTA = '0'

validator = ValueQuotaValidator()
serializer = ValueSerializer()
serializer.context['view'] = MockedView()

validator({
'value_type': 'file'
}, serializer)

0 comments on commit 6cc0dbd

Please sign in to comment.