MCPcopy Create free account
hub / github.com/ExtendDB/extenddb / test_export_dynamodb_json

Method test_export_dynamodb_json

tests/test_import_export.py:109–139  ·  view source on GitHub ↗

Export table to DYNAMODB_JSON format.

(self, dynamodb_client, populated_table)

Source from the content-addressed store, hash-verified

107 return name
108
109 def test_export_dynamodb_json(self, dynamodb_client, populated_table):
110 """Export table to DYNAMODB_JSON format."""
111 table_name = populated_table
112 desc = dynamodb_client.describe_table(TableName=table_name)
113 table_arn = desc["Table"]["TableArn"]
114
115 with tempfile.NamedTemporaryFile(suffix=".json", delete=False) as f:
116 export_path = f.name
117
118 try:
119 resp = extenddb_request("ExportTableToPointInTime", {
120 "TableArn": table_arn,
121 "FilePath": export_path,
122 "ExportFormat": "DYNAMODB_JSON",
123 })
124 export_desc = resp["ExportDescription"]
125 assert export_desc["ExportStatus"] == "COMPLETED"
126 assert export_desc["ItemCount"] == 5
127 assert export_desc["ExportFormat"] == "DYNAMODB_JSON"
128
129 # Verify file contents.
130 with open(export_path) as f:
131 lines = [line.strip() for line in f if line.strip()]
132 assert len(lines) == 5
133
134 for line in lines:
135 obj = json.loads(line)
136 assert "Item" in obj
137 assert "pk" in obj["Item"]
138 finally:
139 os.unlink(export_path)
140
141 def test_export_empty_table(self, dynamodb_client, unique_table_name, cleanup_table):
142 """Export an empty table produces empty file."""

Callers

nothing calls this directly

Calls 2

extenddb_requestFunction · 0.85
describe_tableMethod · 0.80

Tested by

no test coverage detected