当前位置: 首页>>代码示例>>Python>>正文


Python SubscriptionFactory.create_batch方法代码示例

本文整理汇总了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">')
开发者ID:Athenolabs,项目名称:silver,代码行数:33,代码来源:test_subscription.py

示例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
开发者ID:oucsaw,项目名称:silver,代码行数:27,代码来源:test_subscription.py


注:本文中的silver.tests.factories.SubscriptionFactory.create_batch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。