class Arvados::V1::FiltersTest < ActionController::TestCase
test '"not in" filter passes null values' do
- @controller = Arvados::V1::GroupsController.new
+ @controller = Arvados::V1::ContainerRequestsController.new
authorize_with :admin
- get :index, {
- filters: [ ['group_class', 'not in', ['project']] ],
- controller: 'groups',
+ get :index, params: {
+ filters: [ ['container_uuid', 'not in', ['zzzzz-dz642-queuedcontainer', 'zzzzz-dz642-runningcontainr']] ],
+ controller: 'container_requests',
}
assert_response :success
found = assigns(:objects)
- assert_includes(found.collect(&:group_class), nil,
- "'group_class not in ['project']' filter should pass null")
+ assert_includes(found.collect(&:container_uuid), nil,
+ "'container_uuid not in [zzzzz-dz642-queuedcontainer, zzzzz-dz642-runningcontainr]' filter should pass null")
end
test 'error message for non-array element in filters array' do
@controller = Arvados::V1::CollectionsController.new
authorize_with :active
- get :index, {
+ get :index, params: {
filters: [{bogus: 'filter'}],
}
assert_response 422
test 'error message for full text search on a specific column' do
@controller = Arvados::V1::CollectionsController.new
authorize_with :active
- get :index, {
+ get :index, params: {
filters: [['uuid', '@@', 'abcdef']],
}
assert_response 422
test 'difficult characters in full text search' do
@controller = Arvados::V1::CollectionsController.new
authorize_with :active
- get :index, {
+ get :index, params: {
filters: [['any', '@@', 'a|b"c']],
}
assert_response :success
test 'array operand in full text search' do
@controller = Arvados::V1::CollectionsController.new
authorize_with :active
- get :index, {
+ get :index, params: {
filters: [['any', '@@', ['abc', 'def']]],
}
assert_response 422
timestamp = mine.modified_at.strftime('%Y-%m-%dT%H:%M:%S.%NZ')
@controller = Arvados::V1::CollectionsController.new
authorize_with :active
- get :index, {
+ get :index, params: {
filters: [['modified_at', operator, timestamp],
['uuid', '=', mine.uuid]],
}
@controller = Arvados::V1::GroupsController.new
authorize_with :admin
- get :contents, {
+ get :contents, params: {
format: :json,
count: 'none',
limit: 1000,
- filters: [['any', '@@', Rails.configuration.uuid_prefix]],
+ filters: [['any', '@@', Rails.configuration.ClusterID]],
}
assert_response :success
@controller = Arvados::V1::GroupsController.new
- get :contents, {
+ get :contents, params: {
format: :json,
count: 'none',
limit: 1000,
offset: '5',
last_object_class: 'PipelineInstance',
- filters: [['any', '@@', Rails.configuration.uuid_prefix]],
+ filters: [['any', '@@', Rails.configuration.ClusterID]],
}
assert_response :success
['prop2', '<=', 5, [:collection_with_prop2_1, :collection_with_prop2_5], []],
['prop2', '>=', 1, [:collection_with_prop2_1, :collection_with_prop2_5], []],
['<http://schema.org/example>', '=', "value1", [:collection_with_uri_prop], []],
+ ['listprop', 'contains', 'elem1', [:collection_with_list_prop_odd, :collection_with_listprop_elem1], [:collection_with_list_prop_even]],
+ ['listprop', '=', 'elem1', [:collection_with_listprop_elem1], [:collection_with_list_prop_odd]],
+ ['listprop', 'contains', 5, [:collection_with_list_prop_odd], [:collection_with_list_prop_even, :collection_with_listprop_elem1]],
+ ['listprop', 'contains', 'elem2', [:collection_with_list_prop_even], [:collection_with_list_prop_odd, :collection_with_listprop_elem1]],
+ ['listprop', 'contains', 'ELEM2', [], [:collection_with_list_prop_even]],
+ ['listprop', 'contains', 'elem8', [], [:collection_with_list_prop_even]],
+ ['listprop', 'contains', 4, [:collection_with_list_prop_even], [:collection_with_list_prop_odd, :collection_with_listprop_elem1]],
].each do |prop, op, opr, inc, ex|
test "jsonb filter properties.#{prop} #{op} #{opr})" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: SafeJSON.dump([ ["properties.#{prop}", op, opr] ]),
limit: 1000
}
test "jsonb hash 'exists' and '!=' filter" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['properties.prop1', 'exists', true], ['properties.prop1', '!=', 'value1'] ]
}
assert_response :success
test "jsonb array 'exists'" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['storage_classes_confirmed.default', 'exists', true] ]
}
assert_response :success
test "jsonb hash alternate form 'exists' and '!=' filter" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['properties', 'exists', 'prop1'], ['properties.prop1', '!=', 'value1'] ]
}
assert_response :success
test "jsonb array alternate form 'exists' filter" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['storage_classes_confirmed', 'exists', 'default'] ]
}
assert_response :success
test "jsonb 'exists' must be boolean" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['properties.prop1', 'exists', nil] ]
}
assert_response 422
test "jsonb checks column exists" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['puppies.prop1', '=', 'value1'] ]
}
assert_response 422
test "jsonb checks column is valid" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['name.prop1', '=', 'value1'] ]
}
assert_response 422
test "jsonb invalid operator" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: [ ['properties.prop1', '###', 'value1'] ]
}
assert_response 422
test "replication_desired = 2" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
- get :index, {
+ get :index, params: {
filters: SafeJSON.dump([ ['replication_desired', '=', 2] ])
}
assert_response :success
assert_includes(found, collections(:replication_desired_2_unconfirmed).uuid)
assert_includes(found, collections(:replication_desired_2_confirmed_2).uuid)
end
-
end