本文整理汇总了Python中orator.orm.builder.Builder.pluck方法的典型用法代码示例。如果您正苦于以下问题:Python Builder.pluck方法的具体用法?Python Builder.pluck怎么用?Python Builder.pluck使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orator.orm.builder.Builder
的用法示例。
在下文中一共展示了Builder.pluck方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pluck_with_model_found
# 需要导入模块: from orator.orm.builder import Builder [as 别名]
# 或者: from orator.orm.builder.Builder import pluck [as 别名]
def test_pluck_with_model_found(self):
builder = Builder(self.get_mock_query_builder())
model = {'name': 'foo'}
builder.first = mock.MagicMock(return_value=model)
self.assertEqual('foo', builder.pluck('name'))
builder.first.assert_called_once_with(
['name']
)
示例2: test_pluck_with_model_not_found
# 需要导入模块: from orator.orm.builder import Builder [as 别名]
# 或者: from orator.orm.builder.Builder import pluck [as 别名]
def test_pluck_with_model_not_found(self):
builder = Builder(self.get_mock_query_builder())
builder.first = mock.MagicMock(return_value=None)
self.assertIsNone(builder.pluck('name'))