From b6caffc7e301950eb6762630c5f5972ef4a81e91 Mon Sep 17 00:00:00 2001 From: mdorf Date: Thu, 18 Jul 2024 10:54:07 -0700 Subject: [PATCH 1/2] initial develop branch commit --- Gemfile.lock | 54 +++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a8b0b7c..8ba832f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,15 +21,15 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) base64 (0.2.0) - bigdecimal (3.1.5) + bigdecimal (3.1.8) coderay (1.1.3) - concurrent-ruby (1.2.2) - excon (0.109.0) - faraday (2.7.12) + concurrent-ruby (1.3.3) + excon (0.111.0) + faraday (2.8.1) base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) @@ -41,48 +41,50 @@ GEM faraday-multipart (1.0.4) multipart-post (~> 2) faraday-net_http (3.0.2) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) - json (2.6.3) + json (2.7.2) language_server-protocol (3.17.0.3) lz4-ruby (0.3.3) - method_source (1.0.0) - minitest (5.20.0) + method_source (1.1.0) + minitest (5.24.1) minitest-hooks (1.5.1) minitest (> 5.3) multi_json (1.15.0) - multipart-post (2.3.0) - oj (3.16.3) + multipart-post (2.4.1) + oj (3.16.4) bigdecimal (>= 3.0) - parallel (1.23.0) - parser (3.2.2.4) + parallel (1.25.1) + parser (3.3.4.0) ast (~> 2.4.1) racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (5.0.4) - racc (1.7.3) + public_suffix (5.1.1) + racc (1.8.0) rainbow (3.1.1) - rake (13.1.0) - regexp_parser (2.8.2) - rexml (3.2.6) - rubocop (1.57.2) + rake (13.2.1) + regexp_parser (2.9.2) + rexml (3.3.2) + strscan + rubocop (1.65.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) spawnling (2.1.5) + strscan (3.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) @@ -103,4 +105,4 @@ DEPENDENCIES rubocop (~> 1.43) BUNDLED WITH - 2.3.22 + 2.4.22 From 77f5afb6cbbe25b3de4c8a555dcd00715762b312 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Mon, 28 Jul 2025 16:22:46 -0700 Subject: [PATCH 2/2] test: avoid following PURL redirects and split PURL tests into separate file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated PURL-related tests to assert only the HTTP 302 status and Location header, without following the redirect to the BioPortal UI. This avoids triggering Cloudflare bot protection during CI runs. - We do not want to test UI behavior here — we only verify that the correct redirect is served by the PURL resolver. Testing how the UI handles or rewrites URLs (e.g., with query parameters or concept ID fragments) is out of scope for these tests. - Split PURL resolution tests into a new file `test_class_purl.rb` to separate concerns from core class model tests in `test_class.rb`. --- test/models/test_class.rb | 55 ------------------------------- test/models/test_class_purl.rb | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 test/models/test_class_purl.rb diff --git a/test/models/test_class.rb b/test/models/test_class.rb index 0229ffe..b6a07e5 100644 --- a/test/models/test_class.rb +++ b/test/models/test_class.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'faraday/follow_redirects' require_relative '../test_case' class ClassTest < LinkedData::Client::TestCase @@ -16,58 +15,4 @@ def test_find assert_equal ontology, cls.links['ontology'] assert cls.hasChildren end - - # Test PURL generation for a class in an OWL format ontology - def test_purl_owl - cls = LinkedData::Client::Models::Class.find( - 'http://bioontology.org/ontologies/Activity.owl#Activity', - 'https://data.bioontology.org/ontologies/BRO' - ) - refute_nil cls - - res = fetch_response(cls.purl) - assert_equal 200, res.status - assert_equal 'https://bioportal.bioontology.org/ontologies/BRO'\ - '?p=classes&conceptid=http%3A%2F%2Fbioontology.org%2Fontologies%2FActivity.owl%23Activity', - res.env[:url].to_s - end - - # Test PURL generation for a class in a UMLS format ontology - def test_purl_umls - cls = LinkedData::Client::Models::Class.find( - 'http://purl.bioontology.org/ontology/SNOMEDCT/64572001', - 'https://bioportal.bioontology.org/ontologies/SNOMEDCT' - ) - refute_nil cls - - res = fetch_response(cls.purl) - assert_equal 200, res.status - assert_equal 'https://bioportal.bioontology.org/ontologies/SNOMEDCT?p=classes&conceptid=64572001', - res.env[:url].to_s - end - - # Test PURL generation for a class in an OBO format ontology - def test_purl_obo - cls = LinkedData::Client::Models::Class.find( - 'http://purl.obolibrary.org/obo/DOID_4', - 'https://bioportal.bioontology.org/ontologies/DOID' - ) - refute_nil cls - - res = fetch_response(cls.purl) - assert_equal 200, res.status - assert_equal 'https://bioportal.bioontology.org/ontologies/DOID'\ - '?p=classes&conceptid=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FDOID_4', - res.env[:url].to_s - end - - private - - def fetch_response(url) - conn = Faraday.new do |f| - f.response :follow_redirects - f.adapter Faraday.default_adapter - end - conn.get(url) - end end diff --git a/test/models/test_class_purl.rb b/test/models/test_class_purl.rb new file mode 100644 index 0000000..e9893f7 --- /dev/null +++ b/test/models/test_class_purl.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require_relative '../test_case' + +class ClassTest < LinkedData::Client::TestCase + + # Test PURL generation for a class in an OWL format ontology + def test_purl_owl + cls = LinkedData::Client::Models::Class.find( + 'http://bioontology.org/ontologies/Activity.owl#Activity', + 'https://data.bioontology.org/ontologies/BRO' + ) + refute_nil cls + + res = fetch_response(cls.purl) + assert_equal 302, res.status + assert_equal 'https://bioportal.bioontology.org/ontologies/BRO'\ + '/classes?conceptid=http%3A%2F%2Fbioontology.org%2Fontologies%2FActivity.owl%23Activity', + res.headers['location'] + end + + # Test PURL generation for a class in a UMLS format ontology + def test_purl_umls + cls = LinkedData::Client::Models::Class.find( + 'http://purl.bioontology.org/ontology/SNOMEDCT/64572001', + 'https://bioportal.bioontology.org/ontologies/SNOMEDCT' + ) + refute_nil cls + + res = fetch_response(cls.purl) + assert_equal 302, res.status + assert_equal 'https://bioportal.bioontology.org/ontologies/SNOMEDCT/classes/64572001', + res.headers['location'] + end + + # Test PURL generation for a class in an OBO format ontology + def test_purl_obo + cls = LinkedData::Client::Models::Class.find( + 'http://purl.obolibrary.org/obo/DOID_4', + 'https://bioportal.bioontology.org/ontologies/DOID' + ) + refute_nil cls + + res = fetch_response(cls.purl) + assert_equal 302, res.status + assert_equal 'https://bioportal.bioontology.org/ontologies/DOID'\ + '/classes?conceptid=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FDOID_4', + res.headers['location'] + end + + private + + def fetch_response(url) + conn = Faraday.new do |f| + f.adapter Faraday.default_adapter + end + conn.get(url) + end +end