Skip to content

Commit

Permalink
optimize api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Oct 26, 2023
1 parent f3bb98a commit 200a155
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 189f5898e1e2422a647f3937495c3ea1c9894350
revision: 0b0414dc1af8ddac39642ce23be5970de5acc00c
branch: feature/migrate-to-virtuoso
specs:
ontologies_linked_data (0.0.1)
Expand Down
2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8984/solr/prop_search_core1"
MGREP_HOST = ENV.include?("MGREP_HOST") ? ENV["MGREP_HOST"] : "localhost"
MGREP_PORT = ENV.include?("MGREP_PORT") ? ENV["MGREP_PORT"] : 55556
GOO_SLICES = ENV["GOO_SLICES"] || 500

begin
# For prefLabel extract main_lang first, or anything if no main found.
# For other properties only properties with a lang that is included in main_lang are used
Goo.main_languages = ['en']
Goo.use_cache = false
Goo.slice_loading_size = GOO_SLICES.to_i
rescue NoMethodError
puts "(CNFG) >> Goo.main_lang not available"
end
Expand Down
12 changes: 9 additions & 3 deletions test/controllers/test_annotator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ def self.before_suite
end

LinkedData::SampleData::Ontology.delete_ontologies_and_submissions
@@ontologies = LinkedData::SampleData::Ontology.sample_owl_ontologies
@@ontologies = LinkedData::SampleData::Ontology.sample_owl_ontologies(process_submission: true,
process_options: {
process_rdf: true,
extract_metadata: false,
index_search: true
})
annotator = Annotator::Models::NcboAnnotator.new
annotator.init_redis_for_tests()
annotator.create_term_cache_from_ontologies(@@ontologies, false)
Expand Down Expand Up @@ -348,15 +353,16 @@ def self.mapping_test_set
classes = []
class_id = terms_a[i]
ont_acr = onts_a[i]
sub = LinkedData::Models::Ontology.find(ont_acr).first.latest_submission
sub = LinkedData::Models::Ontology.find(ont_acr).first.latest_submission(status: :any)
binding.pry if sub.nil?
sub.bring(ontology: [:acronym])
c = LinkedData::Models::Class.find(RDF::URI.new(class_id))
.in(sub)
.first
classes << c
class_id = terms_b[i]
ont_acr = onts_b[i]
sub = LinkedData::Models::Ontology.find(ont_acr).first.latest_submission
sub = LinkedData::Models::Ontology.find(ont_acr).first.latest_submission(status: :any)
sub.bring(ontology: [:acronym])
c = LinkedData::Models::Class.find(RDF::URI.new(class_id))
.in(sub)
Expand Down
3 changes: 1 addition & 2 deletions test/controllers/test_batch_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

class TestBatchController < TestCase
def self.before_suite
LinkedData::SampleData::Ontology.delete_ontologies_and_submissions
@@ontologies = LinkedData::SampleData::Ontology.sample_owl_ontologies
@@ontologies = LinkedData::SampleData::Ontology.sample_owl_ontologies(process_submission: true)
end

def test_class_batch_one_ontology
Expand Down
4 changes: 3 additions & 1 deletion test/controllers/test_classes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ def self.before_suite
submission_count: 3,
submissions_to_process: [1, 2],
process_submission: true,
random_submission_count: false}
random_submission_count: false,
process_options: {process_rdf: true, extract_metadata: false}
}
return LinkedData::SampleData::Ontology.create_ontologies_and_submissions(options)
end

Expand Down
1 change: 1 addition & 0 deletions test/controllers/test_collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TestCollectionsController < TestCase
def self.before_suite
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: {process_rdf: true, extract_metadata: false},
acronym: 'INRAETHES',
name: 'INRAETHES',
file_path: './test/data/ontology_files/thesaurusINRAE_nouv_structure.rdf',
Expand Down
3 changes: 3 additions & 0 deletions test/controllers/test_external_mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def self.before_suite
end
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: {process_rdf: true, extract_metadata: false},
acronym: "BRO-TEST-MAP",
name: "BRO-TEST-MAP",
file_path: "./test/data/ontology_files/BRO_v3.2.owl",
Expand All @@ -22,6 +23,7 @@ def self.before_suite
})
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: {process_rdf: true, extract_metadata: false},
acronym: "CNO-TEST-MAP",
name: "CNO-TEST-MAP",
file_path: "./test/data/ontology_files/CNO_05.owl",
Expand All @@ -30,6 +32,7 @@ def self.before_suite
})
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: {process_rdf: true, extract_metadata: false},
acronym: "FAKE-TEST-MAP",
name: "FAKE-TEST-MAP",
file_path: "./test/data/ontology_files/fake_for_mappings.owl",
Expand Down
5 changes: 2 additions & 3 deletions test/controllers/test_instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TestInstancesController < TestCase
def self.before_suite
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: { process_rdf: true, extract_metadata: false, generate_missing_labels: false},
acronym: 'XCT-TEST-INST',
name: 'XCT-TEST-INST',
file_path: './test/data/ontology_files/XCTontologyvtemp2.owl',
Expand All @@ -13,9 +14,6 @@ def self.before_suite
})
end

def self.after_suite
LinkedData::SampleData::Ontology.delete_ontologies_and_submissions
end

def test_first_default_page
ont = Ontology.find('XCT-TEST-INST-0').include(:acronym).first
Expand Down Expand Up @@ -52,6 +50,7 @@ def test_all_instance_pages
assert last_response.ok?
instance_count = instance_count + response['collection'].size
end while response['nextPage']

assert_equal 714, instance_count

# Next page should have no results.
Expand Down
3 changes: 3 additions & 0 deletions test/controllers/test_mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def self.before_suite
end
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: { process_rdf: true, extract_metadata: false},
acronym: "BRO-TEST-MAP",
name: "BRO-TEST-MAP",
file_path: "./test/data/ontology_files/BRO_v3.2.owl",
Expand All @@ -23,6 +24,7 @@ def self.before_suite
})
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: { process_rdf: true, extract_metadata: false},
acronym: "CNO-TEST-MAP",
name: "CNO-TEST-MAP",
file_path: "./test/data/ontology_files/CNO_05.owl",
Expand All @@ -31,6 +33,7 @@ def self.before_suite
})
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options: { process_rdf: true, extract_metadata: false},
acronym: "FAKE-TEST-MAP",
name: "FAKE-TEST-MAP",
file_path: "./test/data/ontology_files/fake_for_mappings.owl",
Expand Down
1 change: 0 additions & 1 deletion test/helpers/test_http_cache_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class TestHTTPCacheHelper < TestCaseHelpers

def self.before_suite
raise Exception, "Redis is unavailable, caching will not function" if LinkedData::HTTPCache.redis.ping.nil?
self.new("before_suite").delete_ontologies_and_submissions
ontologies = self.new("before_suite")._ontologies
@@ontology = ontologies.shift
@@ontology_alt = ontologies.shift
Expand Down
3 changes: 3 additions & 0 deletions test/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def app
# @option options [TrueClass, FalseClass] :random_submission_count Use a random number of submissions between 1 and :submission_count
# @option options [TrueClass, FalseClass] :process_submission Parse the test ontology file
def create_ontologies_and_submissions(options = {})
if options[:process_submission] && options[:process_options].nil?
options[:process_options] = { process_rdf: true, extract_metadata: false, generate_missing_labels: false }
end
LinkedData::SampleData::Ontology.create_ontologies_and_submissions(options)
end

Expand Down

0 comments on commit 200a155

Please sign in to comment.