本文整理汇总了Python中mockthink.test.common.assertEqual函数的典型用法代码示例。如果您正苦于以下问题:Python assertEqual函数的具体用法?Python assertEqual怎么用?Python assertEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertEqual函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_filter_by_bracket
def test_filter_by_bracket(self, conn):
res = r.db('x').table('farms').filter(
lambda doc: doc['id'] < 2
).run(conn)
expected = [1]
results = [doc['id'] for doc in res]
assertEqual(expected, results)
开发者ID:scivey,项目名称:mockthink,代码行数:7,代码来源:test_bracket_mapping.py
示例2: 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'])
开发者ID:scivey,项目名称:mockthink,代码行数:32,代码来源:test_grouping.py
示例3: test_error1
def test_error1(self, conn):
try:
r.error('msg').run(conn)
except RqlRuntimeError as err:
rql_err = err
assertEqual('msg', err.message)
assert(isinstance(rql_err, RqlRuntimeError))
开发者ID:scivey,项目名称:mockthink,代码行数:7,代码来源:test_misc.py
示例4: test_simple
def test_simple(self, conn):
res = r.db('x').table('farms').map(
lambda doc: doc['animals'][0]
).run(conn)
assertEqual(
set(['frog', 'horse']),
set(list(res))
)
开发者ID:scivey,项目名称:mockthink,代码行数:8,代码来源:test_bracket_mapping.py
示例5: test_sort_1_attr_2_desc
def test_sort_1_attr_2_desc(self, conn):
expected = [
{'id': 'bill', 'age': 35, 'score': 78},
{'id': 'joe', 'age': 26, 'score': 60},
{'id': 'todd', 'age': 52, 'score': 15},
]
result = r.db('y').table('scores').order_by(r.desc('score')).run(conn)
assertEqual(expected, list(result))
开发者ID:scivey,项目名称:mockthink,代码行数:8,代码来源:test_order_by.py
示例6: test_reduce_1
def test_reduce_1(self, conn):
expected = 191
result = r.db('d').table('nums').map(
lambda doc: doc['points']
).reduce(
lambda elem, acc: elem + acc
).run(conn)
assertEqual(expected, result)
开发者ID:scivey,项目名称:mockthink,代码行数:8,代码来源:test_misc.py
示例7: test_and
def test_and(self, conn):
expected = [
{'id': 'sam'}
]
result = r.db('pdb').table('p').filter(
lambda doc: doc['has_eyes'].and_(doc['age'].lt(20))
).pluck('id').run(conn)
assertEqual(expected, list(result))
开发者ID:scivey,项目名称:mockthink,代码行数:8,代码来源:test_logic.py
示例8: test_distinct_secondary_index
def test_distinct_secondary_index(self, conn):
r.db('d').table('people').index_create('last_name').run(conn)
r.db('d').table('people').index_wait().run(conn)
result = r.db('d').table('people').distinct(index='last_name').run(conn)
result = list(result)
pprint({'result': result})
assertEqual(2, len(result))
assertEqual(set(['Sanders', 'Fudd']), set(result))
开发者ID:scivey,项目名称:mockthink,代码行数:8,代码来源:test_distinct.py
示例9: test_eq
def test_eq(self, conn):
expected = [
{'id': 'sam'}
]
result = r.db('pdb').table('p').filter(
lambda doc: doc['hair_color'] == 'bald'
).pluck('id').run(conn)
assertEqual(expected, list(result))
开发者ID:scivey,项目名称:mockthink,代码行数:8,代码来源:test_logic.py
示例10: test_epoch_time
def test_epoch_time(self, conn):
results = r.db('d').table('people').map(
lambda d: d.merge({'as_epoch': d['last_updated'].to_epoch_time()})
).run(conn)
results = list(results)
jan1 = datetime.datetime(1970, 1, 1, tzinfo=r.make_timezone('00:00'))
for doc in results:
expected = int((doc['last_updated'] - jan1).total_seconds())
assertEqual(expected, doc['as_epoch'])
开发者ID:scivey,项目名称:mockthink,代码行数:9,代码来源:test_time.py
示例11: test_time_of_day
def test_time_of_day(self, conn):
expected = set([
((((12 * 60) + 10) * 60) + 32),
((((17 * 60) + 3) * 60) + 54)
])
result = r.db('d').table('people').map(
lambda doc: doc['last_updated'].time_of_day()
).run(conn)
assertEqual(expected, set(list(result)))
开发者ID:scivey,项目名称:mockthink,代码行数:9,代码来源:test_time.py
示例12: test_do_three
def test_do_three(self, conn):
base = r.db('generic').table('table')
result = r.do(
base.get('one'),
base.get('two'),
base.get('three'),
lambda d1, d2, d3: [d1['name'], d2['name'], d3['name']]
).run(conn)
assertEqual(['One', 'Two', 'Three'], result)
开发者ID:scivey,项目名称:mockthink,代码行数:9,代码来源:test_misc.py
示例13: test_day_of_week
def test_day_of_week(self, conn):
expected = set([
1, # 2014 August 25 -> Monday
2 # 2014 June 3 -> Tuesday
])
result = r.db('d').table('people').map(
lambda doc: doc['last_updated'].day_of_week()
).run(conn)
assertEqual(expected, set(list(result)))
开发者ID:scivey,项目名称:mockthink,代码行数:9,代码来源:test_time.py
示例14: test_date
def test_date(self, conn):
expected = set([
datetime.datetime(2014, 8, 25, tzinfo=r.make_timezone('00:00')),
datetime.datetime(2014, 6, 3, tzinfo=r.make_timezone('00:00'))
])
result = r.db('d').table('people').map(
lambda doc: doc['last_updated'].date()
).run(conn)
assertEqual(expected, set(list(result)))
开发者ID:scivey,项目名称:mockthink,代码行数:9,代码来源:test_time.py
示例15: test_table_drop_2
def test_table_drop_2(self, conn):
expected_1 = set(['one_x', 'one_y'])
expected_2 = set(['two_x'])
r.db('db_two').table_drop('two_y').run(conn)
result_1 = r.db('db_one').table_list().run(conn)
assertEqual(expected_1, set(list(result_1)))
result_2 = r.db('db_two').table_list().run(conn)
assertEqual(expected_2, set(list(result_2)))
开发者ID:scivey,项目名称:mockthink,代码行数:9,代码来源:test_table_db_mod.py
示例16: test_downcase
def test_downcase(self, conn):
expected = set([
'something with spaces',
'some,csv,file',
'someething'
])
result = r.db('library').table('texts').map(
lambda doc: doc['text'].downcase()
).run(conn)
assertEqual(expected, set(list(result)))
开发者ID:scivey,项目名称:mockthink,代码行数:10,代码来源:test_strings.py
示例17: test_upcase
def test_upcase(self, conn):
expected = set([
'SOMETHING WITH SPACES',
'SOME,CSV,FILE',
'SOMEETHING'
])
result = r.db('library').table('texts').map(
lambda doc: doc['text'].upcase()
).run(conn)
assertEqual(expected, set(list(result)))
开发者ID:scivey,项目名称:mockthink,代码行数:10,代码来源:test_strings.py
示例18: test_sort_multi_1_asc
def test_sort_multi_1_asc(self, conn):
expected = [
{'id': 'glen', 'age': 26, 'score': 15},
{'id': 'joe', 'age': 26, 'score': 60},
{'id': 'bill', 'age': 35, 'score': 78},
{'id': 'todd', 'age': 52, 'score': 15},
{'id': 'pale', 'age': 52, 'score': 30}
]
result = r.db('y').table('scores').order_by(r.asc('age'), r.asc('score')).run(conn)
assertEqual(expected, list(result))
开发者ID:scivey,项目名称:mockthink,代码行数:10,代码来源:test_order_by.py
示例19: test_as_obj
def test_as_obj(self):
expected = {
'x': 'x-val',
'y': 'y-val'
}
pairs = [
['x', 'x-val'],
['y', 'y-val']
]
assertEqual(expected, util.as_obj(pairs))
开发者ID:scivey,项目名称:mockthink,代码行数:10,代码来源:test_util.py
示例20: test_filter_during
def test_filter_during(self, conn):
table = r.db('d').table('people')
result = table.filter(
lambda doc: doc['last_updated'].during(
r.time(2014, 6, 1, 'Z'),
r.time(2014, 6, 30, 'Z')
)
).run(conn)
result = list(result)
assertEqual(2, len(result))
开发者ID:scivey,项目名称:mockthink,代码行数:10,代码来源:test_time.py
注:本文中的mockthink.test.common.assertEqual函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论