Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/integration/customizations/test_waiters.py
1567 views
1
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
import random
14
15
import pytest
16
17
import botocore.session
18
from awscli.testutils import unittest, aws, random_chars
19
20
21
class TestDynamoDBWait(unittest.TestCase):
22
def setUp(self):
23
self.session = botocore.session.get_session()
24
self.client = self.session.create_client('dynamodb', 'us-west-2')
25
26
@pytest.mark.slow
27
def test_wait_table_exists(self):
28
# Create a table.
29
table_name = 'awscliddb-%s' % random_chars(10)
30
self.client.create_table(
31
TableName=table_name,
32
ProvisionedThroughput={"ReadCapacityUnits": 5,
33
"WriteCapacityUnits": 5},
34
KeySchema=[{"AttributeName": "foo", "KeyType": "HASH"}],
35
AttributeDefinitions=[{"AttributeName": "foo",
36
"AttributeType": "S"}])
37
self.addCleanup(self.client.delete_table, TableName=table_name)
38
39
# Wait for the table to be active.
40
p = aws(
41
'dynamodb wait table-exists --table-name %s --region us-west-2' %
42
table_name)
43
self.assertEqual(p.rc, 0)
44
45
# Make sure the table is active.
46
parsed = self.client.describe_table(TableName=table_name)
47
self.assertEqual(parsed['Table']['TableStatus'], 'ACTIVE')
48
49