3 class CollectionsApiTest < ActionDispatch::IntegrationTest
6 test "should get index" do
7 get "/arvados/v1/collections", {:format => :json}, auth(:active)
8 assert_response :success
9 assert_equal "arvados#collectionList", json_response['kind']
12 test "get index with filters= (empty string)" do
13 get "/arvados/v1/collections", {:format => :json, :filters => ''}, auth(:active)
14 assert_response :success
15 assert_equal "arvados#collectionList", json_response['kind']
18 test "get index with invalid filters (array of strings) responds 422" do
19 get "/arvados/v1/collections", {
21 :filters => ['uuid', '=', 'ad02e37b6a7f45bbe2ead3c29a109b8a+54'].to_json
24 assert_match /nvalid element.*not an array/, json_response['errors'].join(' ')
27 test "get index with invalid filters (unsearchable column) responds 422" do
28 get "/arvados/v1/collections", {
30 :filters => [['this_column_does_not_exist', '=', 'bogus']].to_json
33 assert_match /nvalid attribute/, json_response['errors'].join(' ')
36 test "get index with invalid filters (invalid operator) responds 422" do
37 get "/arvados/v1/collections", {
39 :filters => [['uuid', ':-(', 'displeased']].to_json
42 assert_match /nvalid operator/, json_response['errors'].join(' ')
45 test "get index with invalid filters (invalid operand type) responds 422" do
46 get "/arvados/v1/collections", {
48 :filters => [['uuid', '=', {foo: 'bar'}]].to_json
51 assert_match /nvalid operand type/, json_response['errors'].join(' ')
54 test "get index with where= (empty string)" do
55 get "/arvados/v1/collections", {:format => :json, :where => ''}, auth(:active)
56 assert_response :success
57 assert_equal "arvados#collectionList", json_response['kind']
60 test "controller 404 response is json" do
61 get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, auth(:active)
63 assert_equal 1, json_response['errors'].length
64 assert_equal true, json_response['errors'][0].is_a?(String)
67 test "object 404 response is json" do
68 get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, auth(:active)
70 assert_equal 1, json_response['errors'].length
71 assert_equal true, json_response['errors'][0].is_a?(String)
74 test "store collection as json" do
75 post "/arvados/v1/collections", {
77 collection: "{\"manifest_text\":\". bad42fa702ae3ea7d888fef11b46f450+44 0:44:md5sum.txt\\n\",\"uuid\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
80 assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['uuid']