def test_bad_media_type(self): '''Tests calling JobConnection.validate_input_files() with a bad media type''' file_desc = ScaleFileDescription() file_desc.add_allowed_media_type(u'application/json') files = {u'Param1': (True, True, file_desc)} conn = JobConnection() conn.add_input_file(u'Param1', True, None, False, False) warnings = conn.validate_input_files(files) self.assertTrue(warnings)
def test_bad_media_type(self): '''Tests calling JobConnection.validate_input_files() with a bad media type''' file_desc = ScaleFileDescription() file_desc.add_allowed_media_type(u'application/json') files = {u'Param1': (True, True, file_desc)} conn = JobConnection() conn.add_input_file(u'Param1', True, None, False) warnings = conn.validate_input_files(files) self.assertTrue(warnings)
def test_successful(self): '''Tests calling JobConnection.validate_input_files() successfully''' file_desc = ScaleFileDescription() file_desc.add_allowed_media_type(u'application/json') file_desc_2 = ScaleFileDescription() file_desc_2.add_allowed_media_type(u'application/json') file_desc_2.add_allowed_media_type(u'text/plain') files = {u'Param1': (True, True, file_desc), u'Param2': (True, False, ScaleFileDescription()), u'Param3': (False, True, file_desc_2), u'Param4': (False, True, file_desc_2)} conn = JobConnection() conn.add_input_file(u'Param1', True, [u'application/json'], False) conn.add_input_file(u'Param2', False, [u'text/plain'], False) conn.add_input_file(u'Param3', False, [u'text/plain'], False) # No exception is success warnings = conn.validate_input_files(files) self.assertFalse(warnings)
def test_successful(self): """Tests calling JobConnection.validate_input_files() successfully""" file_desc = ScaleFileDescription() file_desc.add_allowed_media_type('application/json') file_desc_2 = ScaleFileDescription() file_desc_2.add_allowed_media_type('application/json') file_desc_2.add_allowed_media_type('text/plain') files = {'Param1': (True, True, file_desc), 'Param2': (True, False, ScaleFileDescription()), 'Param3': (False, True, file_desc_2), 'Param4': (False, True, file_desc_2)} conn = JobConnection() conn.add_input_file('Param1', True, ['application/json'], False, False) conn.add_input_file('Param2', False, ['text/plain'], False, False) conn.add_input_file('Param3', False, ['text/plain'], False, False) # No exception is success warnings = conn.validate_input_files(files) self.assertFalse(warnings)