| 
									
										
										
										
											2014-08-27 11:17:06 -04:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							| 
									
										
										
										
											2014-08-26 13:25:50 -04:00
										 |  |  | import six | 
					
						
							| 
									
										
										
										
											2013-02-19 08:26:05 -05:00
										 |  |  | import boto | 
					
						
							| 
									
										
										
										
											2014-08-26 13:25:50 -04:00
										 |  |  | import boto.dynamodb | 
					
						
							| 
									
										
										
										
											2013-08-03 17:21:25 -04:00
										 |  |  | import sure  # noqa | 
					
						
							| 
									
										
										
										
											2013-03-17 18:39:21 -04:00
										 |  |  | import requests | 
					
						
							| 
									
										
										
										
											2014-08-26 13:25:50 -04:00
										 |  |  | import tests.backport_assert_raises | 
					
						
							|  |  |  | from nose.tools import assert_raises | 
					
						
							| 
									
										
										
										
											2013-02-19 20:39:04 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | from moto import mock_dynamodb, mock_dynamodb_deprecated | 
					
						
							| 
									
										
										
										
											2013-02-19 08:26:05 -05:00
										 |  |  | from moto.dynamodb import dynamodb_backend | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-10 15:46:27 -04:00
										 |  |  | from boto.exception import DynamoDBResponseError | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-19 08:26:05 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_dynamodb_deprecated | 
					
						
							| 
									
										
										
										
											2013-02-19 20:01:31 -05:00
										 |  |  | def test_list_tables(): | 
					
						
							| 
									
										
										
										
											2013-02-19 20:39:04 -05:00
										 |  |  |     name = 'TestTable' | 
					
						
							| 
									
										
										
										
											2017-02-23 21:37:43 -05:00
										 |  |  |     dynamodb_backend.create_table( | 
					
						
							|  |  |  |         name, hash_key_attr="name", hash_key_type="S") | 
					
						
							| 
									
										
										
										
											2013-02-19 08:26:05 -05:00
										 |  |  |     conn = boto.connect_dynamodb('the_key', 'the_secret') | 
					
						
							|  |  |  |     assert conn.list_tables() == ['TestTable'] | 
					
						
							| 
									
										
										
										
											2013-02-19 20:39:04 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_dynamodb_deprecated | 
					
						
							| 
									
										
										
										
											2013-03-10 21:16:44 -04:00
										 |  |  | def test_list_tables_layer_1(): | 
					
						
							| 
									
										
										
										
											2017-02-23 21:37:43 -05:00
										 |  |  |     dynamodb_backend.create_table( | 
					
						
							|  |  |  |         "test_1", hash_key_attr="name", hash_key_type="S") | 
					
						
							|  |  |  |     dynamodb_backend.create_table( | 
					
						
							|  |  |  |         "test_2", hash_key_attr="name", hash_key_type="S") | 
					
						
							| 
									
										
										
										
											2013-03-10 21:16:44 -04:00
										 |  |  |     conn = boto.connect_dynamodb('the_key', 'the_secret') | 
					
						
							|  |  |  |     res = conn.layer1.list_tables(limit=1) | 
					
						
							|  |  |  |     expected = {"TableNames": ["test_1"], "LastEvaluatedTableName": "test_1"} | 
					
						
							|  |  |  |     res.should.equal(expected) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     res = conn.layer1.list_tables(limit=1, start_table="test_1") | 
					
						
							|  |  |  |     expected = {"TableNames": ["test_2"]} | 
					
						
							|  |  |  |     res.should.equal(expected) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_dynamodb_deprecated | 
					
						
							| 
									
										
										
										
											2013-03-10 15:46:27 -04:00
										 |  |  | def test_describe_missing_table(): | 
					
						
							|  |  |  |     conn = boto.connect_dynamodb('the_key', 'the_secret') | 
					
						
							| 
									
										
										
										
											2014-08-26 13:25:50 -04:00
										 |  |  |     with assert_raises(DynamoDBResponseError): | 
					
						
							|  |  |  |         conn.describe_table('messages') | 
					
						
							| 
									
										
										
										
											2013-03-17 18:39:21 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_dynamodb_deprecated | 
					
						
							| 
									
										
										
										
											2013-04-13 18:22:26 -04:00
										 |  |  | def test_dynamodb_with_connect_to_region(): | 
					
						
							|  |  |  |     # this will work if connected with boto.connect_dynamodb() | 
					
						
							|  |  |  |     dynamodb = boto.dynamodb.connect_to_region('us-west-2') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     schema = dynamodb.create_schema('column1', str(), 'column2', int()) | 
					
						
							|  |  |  |     dynamodb.create_table('table1', schema, 200, 200) |