3 class ResourceListTest < ActiveSupport::TestCase
5 test 'links_for on a resource list that does not return links' do
8 assert_equal [], results.links_for(api_fixture('users')['active']['uuid'])
11 test 'links_for on non-empty resource list' do
13 results = Group.find(api_fixture('groups')['afolder']['uuid']).contents(include_linked: true)
14 assert_equal [], results.links_for(api_fixture('users')['active']['uuid'])
15 assert_equal [], results.links_for(api_fixture('jobs')['running_cancelled']['uuid'])
16 assert_equal [], results.links_for(api_fixture('jobs')['running']['uuid'], 'bogus-link-class')
17 assert_equal true, results.links_for(api_fixture('jobs')['running']['uuid'], 'name').any?
20 test 'links_for returns all link classes (simulated results)' do
21 folder_uuid = api_fixture('groups')['afolder']['uuid']
22 specimen_uuid = api_fixture('specimens')['in_afolder']['uuid']
24 kind: 'arvados#specimenList',
25 links: [{kind: 'arvados#link',
26 uuid: 'zzzzz-o0j2j-asdfasdfasdfas0',
27 tail_uuid: folder_uuid,
28 head_uuid: specimen_uuid,
31 {kind: 'arvados#link',
32 uuid: 'zzzzz-o0j2j-asdfasdfasdfas1',
33 tail_uuid: folder_uuid,
34 head_uuid: specimen_uuid,
37 {kind: 'arvados#link',
38 uuid: 'zzzzz-o0j2j-asdfasdfasdfas2',
39 tail_uuid: folder_uuid,
40 head_uuid: specimen_uuid,
43 items: [{kind: 'arvados#specimen',
46 arl = ArvadosResourceList.new
47 arl.results = ArvadosApiClient.new.unpack_api_response(api_response)
48 assert_equal(['name', 'foo', nil],
50 links_for(specimen_uuid).
51 collect { |x| x.link_class }),
52 "Expected links_for to return all link_classes")