Esempio n. 1
0
    def put(self, uid=None):
        if not uid:
            try:
                data = convert_rest_request(request.data)
            except TypeError as type_error:
                return error_message(str(type_error),
                                     self.URL,
                                     request_data=request.data)

            result = self._process_data(data)
            if 'error_message' in result:
                logging.warning(
                    'Submission not according to API guidelines! (data could not be parsed)'
                )
                return error_message(result['error_message'],
                                     self.URL,
                                     request_data=data)

            logging.debug('Upload Successful!')
            return success_message(result, self.URL, request_data=data)
        else:
            try:
                update = get_update(request.args)
            except ValueError as value_error:
                return error_message(str(value_error),
                                     self.URL,
                                     request_data={'uid': uid})
            return self._update_analysis(uid, update)
Esempio n. 2
0
 def _put_with_uid(self, uid):
     try:
         update = get_update(request.args)
     except ValueError as value_error:
         return error_message(str(value_error),
                              self.URL,
                              request_data={'uid': uid})
     return self._update_analysis(uid, update)
Esempio n. 3
0
def test_get_update_success():
    assert get_update(dict(update='["any_plugin"]')) == ['any_plugin']
Esempio n. 4
0
def test_get_update_bad(arguments):
    with pytest.raises(ValueError):
        get_update(arguments)