Random asset bug fix: If 2 assets from the same project where returned, the second one would get a corrupt url

This commit is contained in:
2018-10-04 10:11:38 +02:00
parent c81711de53
commit a9848c3fad
2 changed files with 6 additions and 5 deletions

View File

@@ -25,6 +25,8 @@ class RandomFeaturedNodeTest(AbstractCloudTest):
self.fake_now = utcnow()
def test_random_feature_node_returns_3_nodes(self):
from pillar.web.nodes.routes import url_for_node
base_node = {
'name': 'Just a node name',
'project': self.pid,
@@ -58,11 +60,12 @@ class RandomFeaturedNodeTest(AbstractCloudTest):
with self.app.test_request_context():
random_assets = get_random_featured_nodes()
actual_ids = [asset['_id'] for asset in random_assets]
self.assertIs(len(random_assets), 3)
for aid in actual_ids:
self.assertIn(ObjectId(aid), all_asset_ids)
for asset in random_assets:
aid = asset['_id']
self.assertIn(ObjectId(asset['_id']), all_asset_ids)
self.assertEquals(f'/p/default-project/{aid}', url_for_node(node=asset))
def test_random_feature_ignore(self):
def assert_ignored():