Reorganized tests
This commit is contained in:
parent
e86b9f441c
commit
cc1dee03f5
@ -60,176 +60,6 @@ def iterate_results(res):
|
||||
pass
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_eq():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Awesome Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Not So Awesome Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__eq=5
|
||||
)
|
||||
list(results).should.have.length_of(1)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_lt():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Awesome Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Not So Awesome Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__lt=5
|
||||
)
|
||||
list(results).should.have.length_of(2)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_gt():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Awesome Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Not So Awesome Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__gt=1
|
||||
)
|
||||
list(results).should.have.length_of(1)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_lte():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Awesome Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Not So Awesome Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__lte=5
|
||||
)
|
||||
list(results).should.have.length_of(3)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_gte():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Awesome Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Not So Awesome Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__gte=1
|
||||
)
|
||||
list(results).should.have.length_of(2)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
@freeze_time("2012-01-14")
|
||||
@ -810,7 +640,6 @@ def test_query_with_global_indexes():
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_query_with_local_indexes():
|
||||
# testing
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = {
|
||||
'forum_name': 'Cool Forum',
|
||||
@ -824,11 +653,180 @@ def test_query_with_local_indexes():
|
||||
|
||||
item['version'] = '2'
|
||||
item.save(overwrite=True)
|
||||
# Revisit this query once support for QueryFilter is added
|
||||
results = table.query(forum_name__eq='Cool Forum', index='threads_index')
|
||||
results = table.query(forum_name__eq='Cool Forum', index='threads_index', threads__eq=1)
|
||||
list(results).should.have.length_of(1)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_eq():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
results = table.query_2(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__eq=5
|
||||
)
|
||||
list(results).should.have.length_of(1)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_lt():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__lt=5
|
||||
)
|
||||
results = list(results)
|
||||
results.should.have.length_of(2)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_gt():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__gt=1
|
||||
)
|
||||
list(results).should.have.length_of(1)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_lte():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__lte=5
|
||||
)
|
||||
list(results).should.have.length_of(3)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
@mock_dynamodb2
|
||||
def test_query_filter_gte():
|
||||
table = create_table_with_local_indexes()
|
||||
item_data = [
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Check this out!',
|
||||
'version': '1',
|
||||
'threads': 1,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Read this now!',
|
||||
'version': '1',
|
||||
'threads': 5,
|
||||
},
|
||||
{
|
||||
'forum_name': 'Cool Forum',
|
||||
'subject': 'Please read this... please',
|
||||
'version': '1',
|
||||
'threads': 0,
|
||||
}
|
||||
]
|
||||
for data in item_data:
|
||||
item = Item(table, data)
|
||||
item.save(overwrite=True)
|
||||
|
||||
results = table.query(
|
||||
forum_name__eq='Cool Forum', index='threads_index', threads__gte=1
|
||||
)
|
||||
list(results).should.have.length_of(2)
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_reverse_query():
|
||||
conn = boto.dynamodb2.layer1.DynamoDBConnection()
|
||||
|
Loading…
Reference in New Issue
Block a user