本文整理汇总了Python中silver.tests.factories.SubscriptionFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python SubscriptionFactory.create_batch方法的具体用法?Python SubscriptionFactory.create_batch怎么用?Python SubscriptionFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silver.tests.factories.SubscriptionFactory
的用法示例。
在下文中一共展示了SubscriptionFactory.create_batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_subscription_list
# 需要导入模块: from silver.tests.factories import SubscriptionFactory [as 别名]
# 或者: from silver.tests.factories.SubscriptionFactory import create_batch [as 别名]
def test_get_subscription_list(self):
customer = CustomerFactory.create()
SubscriptionFactory.create_batch(40, customer=customer)
url = reverse('subscription-list',
kwargs={'customer_pk': customer.pk})
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_get_subscription_list_reference_filter
# 需要导入模块: from silver.tests.factories import SubscriptionFactory [as 别名]
# 或者: from silver.tests.factories.SubscriptionFactory import create_batch [as 别名]
def test_get_subscription_list_reference_filter(self):
customer = CustomerFactory.create()
subscriptions = SubscriptionFactory.create_batch(3, customer=customer)
url = reverse('subscription-list',
kwargs={'customer_pk': customer.pk})
references = [subscription.reference for subscription in subscriptions]
reference = '?reference=' + references[0]
response = self.client.get(url + reference)
assert len(response.data) == 1
assert response.status_code == status.HTTP_200_OK
reference = '?reference=' + ','.join(references)
response = self.client.get(url + reference)
assert len(response.data) == 3
assert response.status_code == status.HTTP_200_OK
reference = '?reference=' + ','.join(references[:-1]) + ',invalid'
response = self.client.get(url + reference)
assert len(response.data) == 2
assert response.status_code == status.HTTP_200_OK