Path: blob/develop/tests/functional/dynamodb/test_pagination.py
1567 views
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12import json1314from awscli.testutils import BaseAWSCommandParamsTest151617class TestPagination(BaseAWSCommandParamsTest):18def setUp(self):19super(TestPagination, self).setUp()20self.first_response = {21"Items": [{"Key": {"B": "MjEzNw=="}}],22"Count": 1,23"ScannedCount": 1,24"ConsumedCapacity": 1,25"LastEvaluatedKey": {"Key": {"B":"MjEzNw=="}}26}27self.second_response = {28"Items": [],29"Count": 0,30"ScannedCount": 1,31"ConsumedCapacity": 132}3334def test_scan_pagination_binary_last_evaluated_key(self):35self.parsed_responses = [self.first_response, self.second_response]36self.run_cmd('dynamodb scan --table-name test', expected_rc=0)37self.assertEqual(len(self.operations_called), 2)38# The start key in the second request should have been parsed to binary39sent_start_key = self.operations_called[1][1].get('ExclusiveStartKey')40expected_start_key = {"Key": {"B": b'2137'}}41self.assertEqual(sent_start_key, expected_start_key)4243def test_pagination_disabled_works(self):44self.parsed_responses = [self.first_response]45cmd = 'dynamodb scan --table-name table --no-paginate --output json'46stdout, _, _ = self.run_cmd(cmd, expected_rc=0)47# Ensure the base64 encoded last evaluated key is in stdout48self.assertIn('"MjEzNw=="', stdout)495051