예제 #1
0
 def create(self):
     log.info('Writing Data')
     validate_request_body(self.audio_type, self.data)
     response = self.collection.insert_one(self.data)
     output = {
         'Status': 'Successfully Created',
         'Document_ID': str(response.inserted_id)
     }
     return output
예제 #2
0
 def update(self):
     log.info('Updating Data')
     validate_request_body(self.audio_type, self.data)
     updated_data = {"$set": self.data}
     response = self.collection.update_one(self.filter_id, updated_data)
     output = {
         'Status':
         'Successfully Updated'
         if response.modified_count > 0 else "Nothing was updated."
     }
     return output
 def test_wrong_amount_type(self):
     data = {
         'account_id': 'a40bcc03-6f39-418c-ad0b-97e14f522ec1',
         'amount': '123'
     }
     request = helper.validate_request_body(data)['status']
     self.assertEqual(request, 400)
예제 #4
0
def update_amount():
    is_headers_supported = helper.is_headers_supported(
        request.headers['Content-Type'])
    if (is_headers_supported == False):
        return 'Headers not supported', 415

    arg_check = (request.get_json(force=True))
    arg_check1 = ast.literal_eval(json.dumps(arg_check))
    amount = arg_check1.get('amount')
    account_id = arg_check1.get('account_id')
    is_valid_request_body = helper.validate_request_body({
        'amount':
        amount,
        'account_id':
        account_id
    })
    if (is_valid_request_body['status'] == 400):
        return 'Bad request', 400

    id = request.json['account_id']
    amount = request.json['amount']
    update_amount_res = services.update_amount_status(id, amount)
    return jsonify({'balance':
                    update_amount_res['balance']}), update_amount_res['status']
 def test_wrong_account_id_format(self):
     data = {'account_id': 'aca2', 'amount': 12}
     request = helper.validate_request_body(data)['status']
     self.assertEqual(request, 400)
 def test_no_amount(self):
     data = {'amount': 1}
     request = helper.validate_request_body(data)['status']
     self.assertEqual(request, 400)