Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Migrate to Minitest 5 and ActiveSupport 5 #165

Merged
merged 4 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
API_URL=http://localhost:9393
ONTOLOGIES_LINKED_DATA_PATH=
GOO_PATH=
SPARQL_CLIENT_PATH=
ONTOPORTAL_KB=ontoportal_kb
REDIS_HOST=redis-ut
14 changes: 8 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
source 'https://rubygems.org'

gem 'activesupport', '~> 3.2'
gem 'activesupport', '~> 5'
# see https://github.com/ncbo/ontologies_api/issues/69
gem 'bigdecimal', '1.4.2'
gem 'bigdecimal'
# gem 'faraday', '~> 1.9'
gem 'json-schema', '~> 2.0'
gem 'multi_json', '~> 1.0'
gem 'oj', '~> 3.0'
gem 'multi_json'
gem 'oj'
gem 'parseconfig'
gem 'rack'
gem 'rake', '~> 10.0'
Expand Down Expand Up @@ -72,7 +72,9 @@ group :profiling do
end

group :test do
gem 'minitest', '~> 4.0'
gem 'crack', '0.4.5'
gem 'minitest', '~> 5.0'
gem 'minitest-hooks', "~> 1.5"
gem 'minitest-stub_any_instance'
gem 'rack-test'
gem 'simplecov', require: false
Expand Down
59 changes: 37 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ncbo/goo.git
revision: 70007faf43d0d96292809f89f15a27a757ccaa25
revision: aaa3941b48edbc317ec42ba4ecb44c0defeccef6
branch: develop
specs:
goo (0.0.2)
Expand All @@ -16,7 +16,7 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_annotator.git
revision: 2fb892f92f66b876b9793944124f72821f3b3eb8
revision: b2731c98bfef0958fecb440c8648b7755a670895
branch: develop
specs:
ncbo_annotator (0.0.1)
Expand All @@ -27,7 +27,7 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_cron.git
revision: 3bb491139267efc37d3b752888824ca3dd976e85
revision: cf66e7d076a94e6d669ffeb09c6bcd988226ece3
branch: develop
specs:
ncbo_cron (0.0.1)
Expand Down Expand Up @@ -56,7 +56,7 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: c30887ee907acd39500cae6c12f45edb06fe0802
revision: a22fae3150d8e84e3b6fd19223a5ce2111e8ce94
branch: develop
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -103,9 +103,11 @@ GIT
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.22.5)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
activesupport (5.2.8.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
airbrussh (1.5.3)
Expand All @@ -116,7 +118,8 @@ GEM
bcrypt (3.1.20)
bcrypt_pbkdf (1.1.1)
bcrypt_pbkdf (1.1.1-arm64-darwin)
bigdecimal (1.4.2)
bcrypt_pbkdf (1.1.1-x86_64-darwin)
bigdecimal (3.1.8)
builder (3.3.0)
capistrano (3.19.1)
airbrussh (>= 1.0.0)
Expand All @@ -133,8 +136,7 @@ GEM
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
crack (0.4.5)
rexml
cube-ruby (0.0.3)
dante (0.2.0)
Expand All @@ -154,6 +156,7 @@ GEM
faraday (~> 2.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
gapic-common (0.22.0)
faraday (>= 1.9, < 3.a)
Expand All @@ -179,6 +182,7 @@ GEM
google-cloud-errors (1.4.0)
google-protobuf (3.25.5-aarch64-linux)
google-protobuf (3.25.5-arm64-darwin)
google-protobuf (3.25.5-x86_64-darwin)
google-protobuf (3.25.5-x86_64-linux)
googleapis-common-protos (1.6.0)
google-protobuf (>= 3.18, < 5.a)
Expand All @@ -199,6 +203,9 @@ GEM
grpc (1.66.0-arm64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.66.0-x86_64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.66.0-x86_64-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
Expand All @@ -209,13 +216,13 @@ GEM
http-accept (1.7.0)
http-cookie (1.0.7)
domain_name (~> 0.5)
i18n (0.9.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.2)
json-schema (2.8.1)
addressable (>= 2.4)
json_pure (2.7.2)
jwt (2.9.0)
jwt (2.9.1)
base64
kgio (2.11.4)
language_server-protocol (3.17.0.3)
Expand All @@ -233,7 +240,9 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0903)
mini_mime (1.1.5)
minitest (4.7.5)
minitest (5.25.1)
minitest-hooks (1.5.2)
minitest (> 5.3)
minitest-stub_any_instance (1.0.3)
mlanett-redis-lock (0.2.7)
redis
Expand All @@ -257,7 +266,9 @@ GEM
net-ssh (7.2.3)
netrc (0.11.0)
newrelic_rpm (9.13.0)
oj (3.16.1)
oj (3.16.6)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
omni_logger (0.1.4)
logger
os (1.1.4)
Expand Down Expand Up @@ -369,10 +380,11 @@ GEM
ostruct
systemu (2.6.5)
temple (0.10.3)
thread_safe (0.3.6)
tilt (2.4.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo (1.2.11)
thread_safe (~> 0.1)
unicode-display_width (2.6.0)
unicorn (6.1.0)
kgio (~> 2.6)
Expand All @@ -387,35 +399,38 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)

PLATFORMS
aarch64-linux
arm64-darwin-22
x86_64-darwin-23
x86_64-linux

DEPENDENCIES
activesupport (~> 3.2)
activesupport (~> 5)
bcrypt_pbkdf (>= 1.0, < 2.0)
bigdecimal (= 1.4.2)
bigdecimal
capistrano (~> 3)
capistrano-bundler
capistrano-locally
capistrano-rbenv
crack (= 0.4.5)
cube-ruby
ed25519 (>= 1.2, < 2.0)
ffi
goo!
haml (~> 5.2.2)
json-schema (~> 2.0)
minitest (~> 4.0)
minitest (~> 5.0)
minitest-hooks (~> 1.5)
minitest-stub_any_instance
multi_json (~> 1.0)
multi_json
ncbo_annotator!
ncbo_cron!
ncbo_ontology_recommender!
newrelic_rpm
oj (~> 3.0)
oj
ontologies_linked_data!
parseconfig
rack
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/test_annotator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TestAnnotatorController < TestCase

def self.before_suite
def before_suite
@@redis = Redis.new(:host => Annotator.settings.annotator_redis_host, :port => Annotator.settings.annotator_redis_port)
db_size = @@redis.dbsize
if db_size > MAX_TEST_REDIS_SIZE
Expand All @@ -25,7 +25,7 @@ def self.before_suite
annotator = Annotator::Models::NcboAnnotator.new
annotator.init_redis_for_tests()
annotator.create_term_cache_from_ontologies(@@ontologies, false)
mapping_test_set
self.class.mapping_test_set
end

def test_annotate
Expand Down
15 changes: 9 additions & 6 deletions test/controllers/test_batch_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require_relative '../test_case'

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

Expand All @@ -25,7 +26,7 @@ def test_class_batch_one_ontology
assert last_response.ok?
data = MultiJson.load(last_response.body)
classes = data["http://www.w3.org/2002/07/owl#Class"]
assert classes.length == 4
assert_equal 4, classes.length
classes.each do |klass|
assert_instance_of String, klass["prefLabel"]
assert_instance_of Array, klass["synonym"]
Expand Down Expand Up @@ -75,18 +76,19 @@ def test_class_batch_multiple
assert last_response.ok?
data = MultiJson.load(last_response.body)
classes = data["http://www.w3.org/2002/07/owl#Class"]
assert classes.length == 6
assert_equal 6, classes.length
classes.each do |klass|
assert_instance_of String, klass["prefLabel"]
assert !klass["synonym"]
assert klass["prefLabel"] == class_ids[klass["@id"]]
refute klass["synonym"]
assert_equal klass["prefLabel"], class_ids[klass["@id"]]
end
end


def test_class_all_bro
mccl = @@ontologies.select { |y| y.id.to_s.include? "MCCL"}.first
assert mccl, "mccl is not found to execute batch test."
# binding.pry
classes = LinkedData::Models::Class.in(mccl.latest_submission).include(:prefLabel).page(1,500).read_only.all
class_ids = {}
classes.each do |klass|
Expand All @@ -101,9 +103,10 @@ def test_class_all_bro
}
post "/batch/", call_params
assert last_response.ok?
# refute last_response.ok?
data = MultiJson.load(last_response.body)
classes_response = data["http://www.w3.org/2002/07/owl#Class"]
assert classes_response.length == classes.length
assert_equal classes.length, classes_response.length
classes_response.each do |klass|
assert_instance_of String, klass["prefLabel"]
assert klass["prefLabel"] == class_ids[klass["@id"]]
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/test_classes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TestClassesController < TestCase

def self.before_suite
def before_suite
options = {ont_count: 1,
submission_count: 3,
submissions_to_process: [1, 2],
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/test_instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TestInstancesController < TestCase

def self.before_suite
def before_suite
LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
acronym: 'XCT-TEST-INST',
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/test_mappings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class TestMappingsController < TestCase

def self.before_suite

def before_suite
self.backend_4s_delete
["BRO-TEST-MAP-0","CNO-TEST-MAP-0","FAKE-TEST-MAP-0"].each do |acr|
LinkedData::Models::OntologySubmission.where(ontology: [acronym: acr]).to_a.each do |s|
s.delete
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/test_metrics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TestMetricsController < TestCase

def self.before_suite
def before_suite
if OntologySubmission.all.count > 100
puts "this test is going to wipe out all submission and ontologies. probably this is not a test env."
return
Expand Down
Loading
Loading