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

Feature: Add test for parent categories #97

Merged
merged 4 commits into from
Oct 10, 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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 651d2f4226004c2311120e900a936101ee509865
revision: 25819bc9bff2313a9ac4fc717241d37051bcdf4f
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -406,6 +409,7 @@ GEM
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
Expand Down
32 changes: 31 additions & 1 deletion test/controllers/test_categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,34 @@ def test_delete_category
get "/categories/#{acronym}"
assert last_response.status == 404
end
end

def test_parent_category
parent_category1 = LinkedData::Models::Category.new(
acronym: "PARENT1",
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",
name: "Sample Category",
description: "This is a sample category.",
parentCategory: [parent_category1, parent_category2]
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
)
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
Loading