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


Python ProviderFactory.create_batch方法代码示例

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

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


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