From 9ed4f62600e89a3f7c5cf061c50d13094cd68c4d Mon Sep 17 00:00:00 2001 From: Jansen Kantor Date: Mon, 29 Jan 2024 11:08:01 -0500 Subject: [PATCH] Jkantor/blank content (#2167) * test: reproduce issue * fix: allow blank type * chore: version --- openassessment/__init__.py | 2 +- .../xblock/ui_mixins/mfe/submission_serializers.py | 2 +- .../xblock/ui_mixins/mfe/test_mfe_mixin.py | 13 ++++++++++--- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/openassessment/__init__.py b/openassessment/__init__.py index e30468d86f..94916d98f8 100644 --- a/openassessment/__init__.py +++ b/openassessment/__init__.py @@ -2,4 +2,4 @@ Initialization Information for Open Assessment Module """ -__version__ = '6.0.29' +__version__ = '6.0.30' diff --git a/openassessment/xblock/ui_mixins/mfe/submission_serializers.py b/openassessment/xblock/ui_mixins/mfe/submission_serializers.py index 55ecbef919..8d60193037 100644 --- a/openassessment/xblock/ui_mixins/mfe/submission_serializers.py +++ b/openassessment/xblock/ui_mixins/mfe/submission_serializers.py @@ -136,7 +136,7 @@ class AddFileRequestSerializer(Serializer): fileDescription = CharField(source='description') fileName = CharField(source='name') fileSize = IntegerField(source='size', min_value=0) - contentType = CharField() + contentType = CharField(allow_blank=True) class FileUploadCallbackRequestSerializer(Serializer): diff --git a/openassessment/xblock/ui_mixins/mfe/test_mfe_mixin.py b/openassessment/xblock/ui_mixins/mfe/test_mfe_mixin.py index c8034cf76d..8d91f157ba 100644 --- a/openassessment/xblock/ui_mixins/mfe/test_mfe_mixin.py +++ b/openassessment/xblock/ui_mixins/mfe/test_mfe_mixin.py @@ -3,6 +3,7 @@ """ from collections import namedtuple from contextlib import contextmanager +import copy import json from unittest.mock import Mock, PropertyMock, patch @@ -727,7 +728,7 @@ def _mock_delete_uploaded_file(self, **kwargs): 'fileName': 'n1', 'fileSize': -1, 'contentType': 'text', - } + }, ) @scenario("data/basic_scenario.xml") def test_bad_inputs(self, xblock, payload): @@ -783,16 +784,22 @@ def test_upload_url_error( assert_error_response(resp, expected_status, expected_code, expected_context) mock_delete_file.assert_called_once_with(self.VALID_FILE_UPLOAD_OBJ.index) + @ddt.data(False, True) @scenario("data/basic_scenario.xml") - def test_upload_files(self, xblock): + def test_upload_files(self, xblock, blank_content_type): """ Test for file upload happy path""" url = 'www.someurl.xyz/fileUpload' mock_args = { 'get_upload_url.return_value': url, 'append_file_data.return_value': [self.VALID_FILE_UPLOAD_OBJ], } + + payload = copy.deepcopy(self.VALID_FILE_UPLOAD_PAYLOAD) + if blank_content_type: + payload['contentType'] = '' + with self._mock_submissions_actions(**mock_args): - resp = self.request_upload_files(xblock, self.VALID_FILE_UPLOAD_PAYLOAD) + resp = self.request_upload_files(xblock, payload) assert resp.status_code == 200 assert resp.json == { 'fileUrl': url, diff --git a/package-lock.json b/package-lock.json index a9527419b5..e84ea41c38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.0.29", + "version": "6.0.30", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index a4b9c7d7fc..62a3390f9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.0.29", + "version": "6.0.30", "repository": "https://github.com/openedx/edx-ora2.git", "dependencies": { "@edx/frontend-build": "8.0.6",