test_nodes.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pillar 作者: armadillica 项目源码 文件源码
def test_short_code_collision(self):
        # Create a second node that has already been shared.
        self.post('/api/nodes', expected_status=201, auth_token='token', json={
            'project': self.project_id,
            'node_type': 'asset',
            'name': 'collider',
            'properties': {},
            'short_code': 'takenX',
        })

        # Mock create_short_code so that it returns predictable short codes.
        codes = ['takenX', 'takenX', 'freeXX']
        with mock.patch('pillar.api.nodes.create_short_code',
                        side_effect=codes) as create_short_link:
            resp = self.post('/api/nodes/%s/share' % self.node_id, auth_token='token',
                             expected_status=201)

        share_data = resp.json()

        self._check_share_data(share_data)
        self.assertEqual(3, create_short_link.call_count)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号