From 1c27d64a169f7c353289b27ae8cadce88bfa99a5 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Sat, 5 Oct 2024 11:01:14 +0200 Subject: [PATCH 1/4] add a test for parent category --- Gemfile | 2 +- Gemfile.lock | 6 ++++- .../controllers/test_categories_controller.rb | 25 ++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index f1b00e71..de4be286 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/add-portal-config-model' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 57397362..774dde55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,7 +57,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 651d2f4226004c2311120e900a936101ee509865 + revision: f7ee9f13db6b89a303ebe86887b932ab035181d7 branch: development specs: ontologies_linked_data (0.0.1) @@ -211,6 +211,9 @@ GEM multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) + grpc (1.65.2) + google-protobuf (>= 3.25, < 5.0) + googleapis-common-protos-types (~> 1.0) grpc (1.65.2-x86_64-linux) google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) @@ -406,6 +409,7 @@ GEM hashdiff (>= 0.4.0, < 2.0.0) PLATFORMS + ruby x86_64-linux DEPENDENCIES diff --git a/test/controllers/test_categories_controller.rb b/test/controllers/test_categories_controller.rb index d7e07cd2..bfbe6fdd 100644 --- a/test/controllers/test_categories_controller.rb +++ b/test/controllers/test_categories_controller.rb @@ -117,4 +117,27 @@ def test_delete_category get "/categories/#{acronym}" assert last_response.status == 404 end -end \ No newline at end of file + + def test_parent_category + parent_category1 = LinkedData::Models::Category.new( + acronym: "PARENT1", + name: "Parent Category 1", + description: "Description for Parent Category 1." + ) + + parent_category2 = LinkedData::Models::Category.new( + acronym: "PARENT2", + name: "Parent Category 2", + description: "Description for Parent Category 2." + ) + + category_instance = LinkedData::Models::Category.new( + acronym: "CAT123", + name: "Sample Category", + description: "This is a sample category.", + parentCategories: [parent_category1, parent_category2] + ) + assert_equal category_instance.parentCategories.first , parent_category1 + assert_equal category_instance.parentCategories.last , parent_category2 + end +end From 129294f63d477d35b195e9135c0de6e23beaf765 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Sat, 5 Oct 2024 11:07:36 +0200 Subject: [PATCH 2/4] use parent category branch in the gemfile --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index de4be286..6abed255 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parent-category-list' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 774dde55..17c45568 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: f7ee9f13db6b89a303ebe86887b932ab035181d7 - branch: development + revision: 4d7d433b5f62a284eef6a37fb20c420fd0f41f70 + branch: feature/parent-category-list specs: ontologies_linked_data (0.0.1) activesupport From 3afae264d9ff2882a9b73bd19c94e07eaf75b652 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Sat, 5 Oct 2024 11:55:12 +0200 Subject: [PATCH 3/4] update test parent category to use parentCategory instead of parentCategories --- Gemfile.lock | 2 +- test/controllers/test_categories_controller.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 17c45568..9fdfcfde 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,7 +57,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 4d7d433b5f62a284eef6a37fb20c420fd0f41f70 + revision: ce7463428dbee569a0ca4ca20fe84861e4a2ce82 branch: feature/parent-category-list specs: ontologies_linked_data (0.0.1) diff --git a/test/controllers/test_categories_controller.rb b/test/controllers/test_categories_controller.rb index bfbe6fdd..3c0377e7 100644 --- a/test/controllers/test_categories_controller.rb +++ b/test/controllers/test_categories_controller.rb @@ -135,9 +135,9 @@ def test_parent_category acronym: "CAT123", name: "Sample Category", description: "This is a sample category.", - parentCategories: [parent_category1, parent_category2] + parentCategory: [parent_category1, parent_category2] ) - assert_equal category_instance.parentCategories.first , parent_category1 - assert_equal category_instance.parentCategories.last , parent_category2 + assert_equal category_instance.parentCategory.first , parent_category1 + assert_equal category_instance.parentCategory.last , parent_category2 end end From 40c5444d5cf0355f7aedcfd84ae002f5a8de0d59 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Thu, 10 Oct 2024 14:00:28 +0200 Subject: [PATCH 4/4] save category and fetch it in test parent category --- Gemfile | 2 +- Gemfile.lock | 4 ++-- test/controllers/test_categories_controller.rb | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 6abed255..de4be286 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parent-category-list' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 9fdfcfde..9c861a4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: ce7463428dbee569a0ca4ca20fe84861e4a2ce82 - branch: feature/parent-category-list + revision: 25819bc9bff2313a9ac4fc717241d37051bcdf4f + branch: development specs: ontologies_linked_data (0.0.1) activesupport diff --git a/test/controllers/test_categories_controller.rb b/test/controllers/test_categories_controller.rb index 3c0377e7..4cfa7a0b 100644 --- a/test/controllers/test_categories_controller.rb +++ b/test/controllers/test_categories_controller.rb @@ -124,12 +124,14 @@ def test_parent_category name: "Parent Category 1", description: "Description for Parent Category 1." ) + parent_category1.save parent_category2 = LinkedData::Models::Category.new( acronym: "PARENT2", name: "Parent Category 2", description: "Description for Parent Category 2." ) + parent_category2.save category_instance = LinkedData::Models::Category.new( acronym: "CAT123", @@ -137,7 +139,12 @@ def test_parent_category description: "This is a sample category.", parentCategory: [parent_category1, parent_category2] ) - assert_equal category_instance.parentCategory.first , parent_category1 - assert_equal category_instance.parentCategory.last , parent_category2 + category_instance.save + + get '/categories/CAT123' + fetched_category = MultiJson.load(last_response.body) + + assert_equal fetched_category["parentCategory"].first , parent_category1.id.to_s + assert_equal fetched_category["parentCategory"].last , parent_category2.id.to_s end end