Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

460
Views
¿Cómo burlarse del servicio AWS DynamoDB?

Mi servicio usa AWS DynamoDB como dependencia. Quiero escribir pruebas unitarias, pero no sé cómo simular el servicio de DynamoDB. ¿Alguien podría ayudarme con eso?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar la biblioteca moto python para simular aws dynamodb,

https://github.com/spulec/moto

moto utiliza un sistema simple basado en decoradores de python, que describe los servicios de AWS. Aquí hay un ejemplo:

 import unittest import boto3 from moto import mock_dynamodb2 class TestDynamo(unittest.TestCase): def setUp(self): pass @mock_dynamodb2 def test_recoverBsaleAssociation(self): table_name = 'test' dynamodb = boto3.resource('dynamodb', 'us-east-1') table = dynamodb.create_table( TableName=table_name, KeySchema=[ { 'AttributeName': 'key', 'KeyType': 'HASH' }, ], AttributeDefinitions=[ { 'AttributeName': 'key', 'AttributeType': 'S' }, ], ProvisionedThroughput={ 'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5 } ) item = {} item['key'] = 'value' table.put_item(Item=item) table = dynamodb.Table(table_name) response = table.get_item( Key={ 'key': 'value' } ) if 'Item' in response: item = response['Item'] self.assertTrue("key" in item) self.assertEquals(item["key"], "value")
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!