本文整理汇总了Python中mockthink.test.common.assertEqUnordered函数的典型用法代码示例。如果您正苦于以下问题:Python assertEqUnordered函数的具体用法?Python assertEqUnordered怎么用?Python assertEqUnordered使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertEqUnordered函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_lambda_lt
def test_filter_lambda_lt(self, conn):
expected = [
{'id': 'bob-id', 'name': 'bob', 'age': 19},
{'id': 'kimye-id', 'name': 'kimye', 'age': 17}
]
result = r.db('x').table('people').filter(lambda p: p['age'] < 20).run(conn)
assertEqUnordered(expected, list(result))
示例2: test_multi_join
def test_multi_join(self, conn):
query = r.db('x').table('employees').eq_join(
'person', r.db('x').table('people')
).map(
lambda d: d['left'].merge({'person': d['right']['name']})
).eq_join(
'job', r.db('x').table('jobs')
).map(
lambda d: d['left'].merge({'job': d['right']['name']})
)
expected = [
{
'id': 'joe-employee-id',
'person': 'joe',
'job': 'Lawyer'
},
{
'id': 'tim-employee-id',
'person': 'tim',
'job': 'Nurse'
},
{
'id': 'bob-employee-id',
'person': 'bob',
'job': 'Assistant'
},
{
'id': 'todd-employee-id',
'person': 'todd',
'job': 'Lawyer'
}
]
assertEqUnordered(expected, list(query.run(conn)))
示例3: test_sub_sub_list
def test_sub_sub_list(self, conn):
expected = [
{'a': 'a-1', 'd': 'd-1'},
{'a': 'a-2', 'd': 'd-2'}
]
result = r.db('some_db').table('things').map(lambda t: t['values'].pluck('a', 'd')).run(conn)
assertEqUnordered(expected, list(result))
示例4: test_filter_lambda_gt
def test_filter_lambda_gt(self, conn):
expected = [
{'id': 'joe-id', 'name': 'joe', 'age': 28},
{'id': 'bill-id', 'name': 'bill', 'age': 35}
]
result = r.db('x').table('people').filter(lambda p: p['age'] > 20).run(conn)
assertEqUnordered(expected, list(result))
示例5: test_get_all_by_id
def test_get_all_by_id(self, conn):
expected = [
{'id': 'anne-id', 'name': 'anne'},
{'id': 'joe-id', 'name': 'joe'},
]
result = r.db('x').table('people').get_all('anne-id', 'joe-id').run(conn)
assertEqUnordered(expected, result)
示例6: test_has_fields_array
def test_has_fields_array(self, conn):
expected = [
{'id': 'todd', 'first_name': 'Todd', 'last_name': 'Last', 'age': 35},
{'id': 'sam', 'first_name': 'Sam', 'last_name': 'SamLast', 'age': 31}
]
result = r.db('x').table('people').has_fields(['last_name', 'age']).run(conn)
assertEqUnordered(expected, list(result))
示例7: test_ungroup_grouped_by_func
def test_ungroup_grouped_by_func(self, conn):
expected = [
{
'group': 'bro',
'reduction': [
{'id': 'joe', 'type': 'bro'},
{'id': 'sam', 'type': 'bro'}
]
},
{
'group': 'hipster',
'reduction': [
{'id': 'bill', 'type': 'hipster'},
{'id': 'todd', 'type': 'hipster'}
]
},
{
'group': 'unknown',
'reduction': [
{'id': 'glenn', 'type': 'unknown'},
]
}
]
result = r.db('x').table('people').group(lambda d: d['type']).ungroup().run(conn)
result = list(result)
assertEqual(3, len(result))
assertEqual(set(['bro', 'hipster', 'unknown']), set([doc['group'] for doc in result]))
is_group = lambda group: lambda doc: doc['group'] == group
for group in ('bro', 'hipster', 'unknown'):
result_group = list(filter(is_group(group), result))[0]
expected_group = list(filter(is_group(group), expected))[0]
assertEqUnordered(expected_group['reduction'], result_group['reduction'])
示例8: test_inner_join_1
def test_inner_join_1(self, conn):
expected = [
{
'left': {
'id': 'joe-emp-id',
'person': 'joe-id',
'job': 'lawyer-id'
},
'right': {
'id': 'joe-id',
'name': 'Joe'
}
},
{
'left': {
'id': 'arnold-emp-id',
'person': 'arnold-id',
'job': 'nurse-id'
},
'right': {
'id': 'arnold-id',
'name': 'Arnold'
}
}
]
result = r.db('jezebel').table('employees').inner_join(
r.db('jezebel').table('people'),
lambda employee, person: employee['person'] == person['id']
).run(conn)
assertEqUnordered(expected, list(result))
示例9: test_merge_toplevel
def test_merge_toplevel(self, conn):
expected = [
{
'id': 'id-1',
'x': {
'x-val': 'x-val-1'
},
'y': {
'y-val': 'y-val-1'
},
'z': 'Z-VALUE'
},
{
'id': 'id-2',
'x': {
'x-val': 'x-val-2'
},
'y': {
'y-val': 'y-val-2'
},
'z': 'Z-VALUE'
}
]
result = r.db('jezebel').table('things').merge({'z': 'Z-VALUE'}).run(conn)
assertEqUnordered(expected, list(result))
示例10: test_map_gt
def test_map_gt(self, conn):
expected = [
True, False, True, False
]
result = r.db('x').table('people').map(
lambda p: p['age'] > 20
).run(conn)
assertEqUnordered(expected, list(result))
示例11: test_between_id_open_left
def test_between_id_open_left(self, conn):
expected = [
{'id': 'joe', 'first_name': 'Joseph', 'last_name': 'Smith'}
]
result = r.db('s').table('people').between(
'bob', 'tom', left_bound='open'
).run(conn)
result = list(result)
assertEqUnordered(expected, result)
示例12: test_update_with_json
def test_update_with_json(self, conn):
expected = [
{'id': 'one', 'nums': [1, 2, 3]},
{'id': 'two', 'nums': [1, 2, 3]}
]
result = r.db('d').table('t').map(
lambda doc: doc.merge(r.json('{"nums": [1, 2, 3]}'))
).run(conn)
assertEqUnordered(expected, list(result))
示例13: test_is_empty_nested
def test_is_empty_nested(self, conn):
expected = [
{'id': 'id-1', 'things_empty': True, 'things': []},
{'id': 'id-2', 'things_empty': False, 'things': ['x', 'y']}
]
result = r.db('some_db').table('some_table').map(
lambda d: d.merge({'things_empty': d['things'].is_empty()})
).run(conn)
assertEqUnordered(expected, list(result))
示例14: test_distinct_table
def test_distinct_table(self, conn):
expected = [
{'id': 'bob-id', 'first_name': 'Bob', 'last_name': 'Sanders', 'age': 35},
{'id': 'sam-id', 'first_name': 'Sam', 'last_name': 'Fudd', 'age': 17},
{'id': 'joe-id', 'first_name': 'Joe', 'last_name': 'Sanders', 'age': 62}
]
result = r.db('d').table('people').distinct().run(conn)
assertEqUnordered(expected, list(result))
示例15: test_lt
def test_lt(self, conn):
expected = [
{'id': 'sam'},
{'id': 'johnson'}
]
result = r.db('pdb').table('p').filter(
lambda doc: doc['age'].lt(20)
).pluck('id').run(conn)
assertEqUnordered(expected, list(result))