test/application_query_test.rb in openseek-api-0.17.4 vs test/application_query_test.rb in openseek-api-0.18

- old
+ new

@@ -7,38 +7,35 @@ class ApplicationServerQueryTest < Test::Unit::TestCase include Fairdom::OpenbisApi def setup - @as_endpoint = 'https://openbis-api.fair-dom.org/openbis/openbis' @as_endpoint = 'https://127.0.0.1:8443/openbis/openbis' - username = 'apiuser' - password = 'apiuser' username = 'seek' password = 'seek' - @token = Authentication.new(username, password, @as_endpoint).login['token'] + @token = Authentication.new(username, password, @as_endpoint, true).login['token'] @options = { entityType: 'Experiment', queryType: 'PROPERTY', property: 'NAME', propertyValue: 'Low light diurnal' } end def local_setup @as_endpoint = 'https://127.0.0.1:8443/openbis/openbis' username = 'seek' password = 'seek' - @token = Authentication.new(username, password, @as_endpoint).login['token'] + @token = Authentication.new(username, password, @as_endpoint, true).login['token'] end def test_query_property - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) experiments = result['experiments'] refute experiments.empty? end def test_query_for_spaces @options = { entityType: 'Space', queryType: 'ATTRIBUTE', attribute: 'PermID', attributeValue: '' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) spaces = result['spaces'] refute spaces.empty? assert_equal 7, spaces.count space = spaces[0] @@ -60,71 +57,71 @@ #assert_equal 'DEFAULT', space['code'] # assert_nil space['description'] end def test_query_property_no_result - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) @options[:propertyValue] = 'Some_value' result = instance.query(@options) assert result.empty? end def test_unrecognized_type - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) invalid_type = 'SomeType' @options[:entityType] = 'Some_value' assert_raise OpenbisQueryException do instance.query(@options) end end def test_empty_property - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) @options[:property] = '' result = instance.query(@options) assert result.empty? end def test_any_property - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) @options[:property] = 'any_property' result = instance.query(@options) assert result.empty? end def test_query_perm_id_attribute - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) @options[:queryType] = 'ATTRIBUTE' @options[:attribute] = 'permId' @options[:attributeValue] = '20180418141729157-47' result = instance.query(@options) experiments = result['experiments'] refute experiments.empty? end def test_query_multiple_perm_id_attribute_values - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) @options[:queryType] = 'ATTRIBUTE' @options[:attribute] = 'permId' @options[:attributeValue] = '20180424181519696-54,20180418141729157-47' result = instance.query(@options) experiments = result['experiments'] refute experiments.empty? end def test_query_all_permid - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) @options[:queryType] = 'ATTRIBUTE' @options[:attribute] = 'PermID' @options[:attributeValue] = '' result = instance.query(@options) refute result['experiments'].empty? end def test_query_for_dataset_gives_rich_metadata @options = { entityType: 'DataSet', queryType: 'ATTRIBUTE', attribute: 'PermID', attributeValue: '20180424182903704-59' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) #puts result @@ -143,11 +140,11 @@ def test_query_for_dataset_can_retrive_sampleonly_dataset puts 'no such test data' return @options = { entityType: 'DataSet', queryType: 'ATTRIBUTE', attribute: 'PermID', attributeValue: '20180418150033700-51' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) puts result @@ -169,11 +166,11 @@ def test_all_datasets_query @options = { entityType: 'DataSet', queryType: 'ALL' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result datasets = result['datasets'] @@ -182,11 +179,11 @@ def test_all_samples_query @options = { entityType: 'Sample', queryType: 'ALL' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result samples = result['samples'] @@ -195,11 +192,11 @@ def test_all_spaces_query @options = { entityType: 'Space', queryType: 'ALL' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result spaces = result['spaces'] @@ -208,11 +205,11 @@ def test_all_experiments_query local_setup @options = { entityType: 'Experiment', queryType: 'ALL' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) puts result.to_json experiments = result['experiments'] @@ -221,11 +218,11 @@ def test_all_experimentstypes_query local_setup @options = { entityType: 'ExperimentType', queryType: 'ALL' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) puts result.to_json types = result['experimenttypes'] @@ -234,11 +231,11 @@ def test_all_sampletypes_query @options = { entityType: 'SampleType', queryType: 'ALL' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result types = result['sampletypes'] @@ -247,11 +244,11 @@ def test_all_datasetstypes_query @options = { entityType: 'DataSetType', queryType: 'ALL' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result types = result['datasettypes'] @@ -263,11 +260,11 @@ def test_samples_with_type_query @options = { entityType: 'Sample', queryType: 'TYPE', typeCode: 'EXPERIMENTAL_STEP' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result samples = result['samples'] @@ -277,11 +274,11 @@ def test_datasets_with_type_query @options = { entityType: 'DataSet', queryType: 'TYPE', typeCode: 'RAW_DATA' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result sets = result['datasets'] @@ -305,11 +302,11 @@ def test_experimentstypes_with_code_query local_setup @options = { entityType: 'ExperimentType', queryType: "ATTRIBUTE", :attribute=>"CODE", :attributeValue=>"DEFAULT_EXPERIMENT" } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) puts result.to_json types = result['experimenttypes'] @@ -321,11 +318,11 @@ local_setup @options = { entityType: 'Experiment', queryType: 'ATTRIBUTE', attribute: 'PermID', attributeValue: '20180424181519696-54'} - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) puts result.to_json exps = result['experiments'] @@ -338,21 +335,21 @@ def test_experiments_with_type_query local_setup @options = { entityType: 'Experiment', queryType: 'TYPE', typeCode: 'DEFAULT_EXPERIMENT' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) puts result.to_json exps = result['experiments'] assert_equal 3, exps.size @options = { entityType: 'Experiment', queryType: 'TYPE', typeCodes: 'DEFAULT_EXPERIMENT,MATERIALS' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result exps = result['experiments'] @@ -363,11 +360,11 @@ def test_type_by_semantic local_setup @options = { entityType: 'SampleType', queryType: 'SEMANTIC', predicateAccessionId: 'is_a', descriptorAccessionId: 'assay' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result sampleTypes = result['sampletypes'] @@ -378,39 +375,39 @@ def test_type_by_codes local_setup @options = { entityType: 'SampleType', queryType: 'ATTRIBUTE', attribute: 'CODE', attributeValue: 'EXPERIMENTAL_STEP' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result sampleTypes = result['sampletypes'] assert_equal 1, sampleTypes.size @options = { entityType: 'SampleType', queryType: 'ATTRIBUTE', attribute: 'CODE', attributeValue: 'UNKNOWN' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result sampleTypes = result['sampletypes'] assert_equal 1, sampleTypes.size @options = { entityType: 'SampleType', queryType: 'ATTRIBUTE', attribute: 'CODE', attributeValue: 'EXPERIMENTAL_STEP,UNKNOWN' } - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) result = instance.query(@options) # puts result sampleTypes = result['sampletypes'] assert_equal 2, sampleTypes.size end def test_checking_sample_with_parent_and_children local_setup - instance = ApplicationServerQuery.new(@as_endpoint, @token) + instance = ApplicationServerQuery.new(@as_endpoint, @token, true) @options[:entityType] = 'Sample' @options[:queryType] = 'ATTRIBUTE' @options[:attribute] = 'PermID' @options[:attributeValue] = '20180418145851124-48'