本文整理汇总了Python中silver.tests.factories.ProviderFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python ProviderFactory.create_batch方法的具体用法?Python ProviderFactory.create_batch怎么用?Python ProviderFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silver.tests.factories.ProviderFactory
的用法示例。
在下文中一共展示了ProviderFactory.create_batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_providers
# 需要导入模块: from silver.tests.factories import ProviderFactory [as 别名]
# 或者: from silver.tests.factories.ProviderFactory import create_batch [as 别名]
def test_get_providers(self):
batch_size = 40
ProviderFactory.create_batch(batch_size)
url = reverse('provider-list')
response = self.client.get(url)
full_url = None
for field in response.data:
full_url = field.get('url', None)
if full_url:
break
if full_url:
domain = full_url.split('/')[2]
full_url = full_url.split(domain)[0] + domain + url
assert response.status_code == status.HTTP_200_OK
assert response._headers['link'] == \
('Link', '<' + full_url + '?page=2; rel="next">, ' +
'<' + full_url + '?page=1; rel="first">, ' +
'<' + full_url + '?page=2; rel="last">')
response = self.client.get(url + '?page=2')
assert response.status_code == status.HTTP_200_OK
assert response._headers['link'] == \
('Link', '<' + full_url + '; rel="prev">, ' +
'<' + full_url + '?page=1; rel="first">, ' +
'<' + full_url + '?page=2; rel="last">')
示例2: test_POST_bulk_providers
# 需要导入模块: from silver.tests.factories import ProviderFactory [as 别名]
# 或者: from silver.tests.factories.ProviderFactory import create_batch [as 别名]
def test_POST_bulk_providers(self):
providers = ProviderFactory.create_batch(5)
raw_providers = json.loads(serializers.serialize('json', providers))
serialized_providers = []
for item in raw_providers:
serialized_providers.append(item['fields'])
url = reverse('provider-list')
response = self.client.post(url, data=json.dumps(serialized_providers),
content_type='application/json')
assert response.status_code == status.HTTP_201_CREATED
assert len(response.data) == 5