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)
评论列表
文章目录