本文整理汇总了Python中fixtureless.Factory.build方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.build方法的具体用法?Python Factory.build怎么用?Python Factory.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fixtureless.Factory
的用法示例。
在下文中一共展示了Factory.build方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_build_with_multi_model_and_multi_count_and_single_initial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_model_and_multi_count_and_single_initial(self):
factory = Factory()
count1 = 2
initial1 = {
'decimal_field': Decimal('10.00')
}
initial_list1 = list()
for _ in itertools.repeat(None, count1):
initial_list1.append(initial1)
count2 = 3
initial2 = {
'char_field': 'test value'
}
initial_list2 = list()
for _ in itertools.repeat(None, count2):
initial_list2.append(initial2)
args = ((ModelOne, initial_list1), (ModelTwo, initial_list2))
models = factory.build(*args)
self.assertEqual(len(models), count1 + count2)
self.assertIsInstance(models[0], ModelOne)
self.assertIsInstance(models[1], ModelOne)
self.assertEqual(models[0].decimal_field, initial1['decimal_field'])
self.assertEqual(models[1].decimal_field, initial1['decimal_field'])
self.assertIsInstance(models[2], ModelTwo)
self.assertIsInstance(models[3], ModelTwo)
self.assertIsInstance(models[4], ModelTwo)
self.assertEqual(models[2].char_field, initial2['char_field'])
self.assertEqual(models[3].char_field, initial2['char_field'])
self.assertEqual(models[4].char_field, initial2['char_field'])
示例2: test_build_with_multi_model_and_multi_count_and_multi_initial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_model_and_multi_count_and_multi_initial(self):
factory = Factory()
initial1_1 = {
'decimal_field': Decimal('10.00')
}
initial1_2 = {
'decimal_field': Decimal('8.00')
}
initial2_1 = {
'char_field': 'test value 1'
}
initial2_2 = {
'char_field': 'test value 2'
}
args = ((ModelOne, [initial1_1, initial1_2]),
(ModelTwo, [initial2_1, initial2_2]))
models = factory.build(*args)
self.assertEqual(len(models), 4)
self.assertIsInstance(models[0], ModelOne)
self.assertIsInstance(models[1], ModelOne)
self.assertEqual(models[0].decimal_field, initial1_1['decimal_field'])
self.assertEqual(models[1].decimal_field, initial1_2['decimal_field'])
self.assertIsInstance(models[2], ModelTwo)
self.assertIsInstance(models[3], ModelTwo)
self.assertEqual(models[2].char_field, initial2_1['char_field'])
self.assertEqual(models[3].char_field, initial2_2['char_field'])
示例3: test_build_with_multi_count
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_count(self):
factory = Factory()
count = 2
models = factory.build(ModelOne, count)
self.assertEqual(len(models), count)
self.assertIsInstance(models[0], ModelOne)
self.assertIsInstance(models[1], ModelOne)
self.assertNotEqual(models[0], models[1])
示例4: test_build_with_multi_model_and_single_count
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_model_and_single_count(self):
factory = Factory()
count1 = 1
count2 = 1
args = ((ModelOne, count1), (ModelTwo, count2))
models = factory.build(*args)
self.assertEqual(len(models), 2)
self.assertIsInstance(models[0], ModelOne)
self.assertIsInstance(models[1], ModelTwo)
示例5: test_build_with_count_and_initial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_count_and_initial(self):
factory = Factory()
count = 1
initial = {
'decimal_field': Decimal('10.00')
}
args = (ModelOne, initial)
model = factory.build(*args)
self.assertIsInstance(model, ModelOne)
self.assertEqual(model.decimal_field, initial['decimal_field'])
示例6: test_build_with_multi_model_and_multi_count
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_model_and_multi_count(self):
factory = Factory()
count1 = 2
count2 = 3
args = ((ModelOne, count1), (ModelTwo, count2))
models = factory.build(*args)
self.assertEqual(len(models), count1 + count2)
self.assertIsInstance(models[0], ModelOne)
self.assertIsInstance(models[1], ModelOne)
self.assertIsInstance(models[2], ModelTwo)
self.assertIsInstance(models[3], ModelTwo)
self.assertIsInstance(models[4], ModelTwo)
示例7: test_build_with_multi_model_and_single_count_and_single_initial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_model_and_single_count_and_single_initial(self):
factory = Factory()
initial1 = {
'decimal_field': Decimal('10.00')
}
initial2 = {
'char_field': 'test value'
}
args = ((ModelOne, initial1), (ModelTwo, initial2))
models = factory.build(*args)
self.assertIsInstance(models[0], ModelOne)
self.assertEqual(models[0].decimal_field, initial1['decimal_field'])
self.assertIsInstance(models[1], ModelTwo)
self.assertEqual(models[1].char_field, initial2['char_field'])
示例8: test_build_with_multi_count_and_single_initial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_count_and_single_initial(self):
factory = Factory()
count = 2
initial1 = {
'decimal_field': Decimal('10.00')
}
initial_list = list()
for _ in itertools.repeat(None, count):
initial_list.append(initial1)
args = (ModelOne, initial_list)
models = factory.build(*args)
self.assertEqual(len(models), count)
self.assertIsInstance(models[0], ModelOne)
self.assertEqual(models[0].decimal_field, initial1['decimal_field'])
self.assertIsInstance(models[1], ModelOne)
self.assertEqual(models[1].decimal_field, initial1['decimal_field'])
示例9: test_build_with_multi_count_and_multi_initial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_count_and_multi_initial(self):
factory = Factory()
count = 2
initial1 = {
'decimal_field': Decimal('10.00')
}
initial2 = {
'decimal_field': Decimal('8.00')
}
args = (ModelOne, [initial1, initial2])
models = factory.build(*args)
self.assertEqual(len(models), count)
self.assertIsInstance(models[0], ModelOne)
self.assertEqual(models[0].decimal_field, initial1['decimal_field'])
self.assertIsInstance(models[1], ModelOne)
self.assertEqual(models[1].decimal_field, initial2['decimal_field'])
示例10: test_build_with_single_count
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_single_count(self):
factory = Factory()
count = 1
args = (ModelOne, count)
model = factory.build(*args)
self.assertIsInstance(model, ModelOne)
示例11: test_build_trivial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_trivial(self):
factory = Factory()
model = factory.build(ModelOne)
self.assertIsInstance(model, ModelOne)
示例12: test_build_with_multi_model_trivial
# 需要导入模块: from fixtureless import Factory [as 别名]
# 或者: from fixtureless.Factory import build [as 别名]
def test_build_with_multi_model_trivial(self):
factory = Factory()
models = factory.build((ModelOne, ), (ModelTwo, ))
self.assertEqual(len(models), 2)
self.assertIsInstance(models[0], ModelOne)
self.assertIsInstance(models[1], ModelTwo)