Skip to content

Commit

Permalink
add another ontologyin test ontology agents test, and assert only the…
Browse files Browse the repository at this point in the history
… number of results and the names
  • Loading branch information
Bilelkihal committed Jul 23, 2024
1 parent bc9a270 commit 8d47007
Showing 1 changed file with 37 additions and 76 deletions.
113 changes: 37 additions & 76 deletions test/controllers/test_ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,82 +283,43 @@ def test_detach_a_view
end

def test_ontology_agents
ontologies_and_submissions = create_ontologies_and_submissions(ont_count: 1, submission_count: 1, process_submission: true)
submission = ontologies_and_submissions[2].first.submissions.last
ontology_acronym = ontologies_and_submissions[1].first
submission.bring(*OntologySubmission.agents_attrs)
submission.publisher = [_create_agent(name: 'Bilel', type: 'person'), _create_agent(name: 'Syphax', type: 'person')]
submission.hasContributor = [_create_agent(name: 'Clement', type: 'person'), _create_agent(name: 'Syphax', type: 'person')]
submission.save
get "/ontologies/#{ontology_acronym}/agents"

expected_result = [{"agentType"=>"person",
"name"=>"Bilel",
"creator"=>"http://data.bioontology.org/users/tim",
"id"=>"http://data.bioontology.org/Agents/35e85b80-25ae-013d-fc07-2cde48001122",
"homepage"=>nil,
"acronym"=>nil,
"email"=>nil,
"identifiers"=>[],
"affiliations"=>[],
"@id"=>"http://data.bioontology.org/Agents/35e85b80-25ae-013d-fc07-2cde48001122",
"@type"=>"http://xmlns.com/foaf/0.1/Agent",
"@context"=>
{"@vocab"=>"http://data.bioontology.org/metadata/",
"agentType"=>"http://data.bioontology.org/metadata/agentType",
"name"=>"http://xmlns.com/foaf/0.1/name",
"homepage"=>"http://xmlns.com/foaf/0.1/homepage",
"acronym"=>"http://www.w3.org/2004/02/skos/core#altLabel",
"email"=>"http://xmlns.com/foaf/0.1/mbox",
"identifiers"=>"http://www.w3.org/ns/adms#identifier",
"affiliations"=>"http://www.w3.org/ns/org#memberOf",
"creator"=>{"@id"=>"http://data.bioontology.org/metadata/User", "@type"=>"@id"},
"@language"=>"en"}},
{"agentType"=>"person",
"name"=>"Syphax",
"creator"=>"http://data.bioontology.org/users/tim",
"id"=>"http://data.bioontology.org/Agents/35fbe2b0-25ae-013d-fc07-2cde48001122",
"homepage"=>nil,
"acronym"=>nil,
"email"=>nil,
"identifiers"=>[],
"affiliations"=>[],
"@id"=>"http://data.bioontology.org/Agents/35fbe2b0-25ae-013d-fc07-2cde48001122",
"@type"=>"http://xmlns.com/foaf/0.1/Agent",
"@context"=>
{"@vocab"=>"http://data.bioontology.org/metadata/",
"agentType"=>"http://data.bioontology.org/metadata/agentType",
"name"=>"http://xmlns.com/foaf/0.1/name",
"homepage"=>"http://xmlns.com/foaf/0.1/homepage",
"acronym"=>"http://www.w3.org/2004/02/skos/core#altLabel",
"email"=>"http://xmlns.com/foaf/0.1/mbox",
"identifiers"=>"http://www.w3.org/ns/adms#identifier",
"affiliations"=>"http://www.w3.org/ns/org#memberOf",
"creator"=>{"@id"=>"http://data.bioontology.org/metadata/User", "@type"=>"@id"},
"@language"=>"en"}},
{"agentType"=>"person",
"name"=>"Clement",
"creator"=>"http://data.bioontology.org/users/tim",
"id"=>"http://data.bioontology.org/Agents/360ed240-25ae-013d-fc07-2cde48001122",
"homepage"=>nil,
"acronym"=>nil,
"email"=>nil,
"identifiers"=>[],
"affiliations"=>[],
"@id"=>"http://data.bioontology.org/Agents/360ed240-25ae-013d-fc07-2cde48001122",
"@type"=>"http://xmlns.com/foaf/0.1/Agent",
"@context"=>
{"@vocab"=>"http://data.bioontology.org/metadata/",
"agentType"=>"http://data.bioontology.org/metadata/agentType",
"name"=>"http://xmlns.com/foaf/0.1/name",
"homepage"=>"http://xmlns.com/foaf/0.1/homepage",
"acronym"=>"http://www.w3.org/2004/02/skos/core#altLabel",
"email"=>"http://xmlns.com/foaf/0.1/mbox",
"identifiers"=>"http://www.w3.org/ns/adms#identifier",
"affiliations"=>"http://www.w3.org/ns/org#memberOf",
"creator"=>{"@id"=>"http://data.bioontology.org/metadata/User", "@type"=>"@id"},
"@language"=>"en"}}]
assert expected_result, MultiJson.load(last_response.body)
ontologies_and_submissions = create_ontologies_and_submissions(ont_count: 2, submission_count: 1, process_submission: true)
submission1 = ontologies_and_submissions[2].first.submissions.last
submission2 = ontologies_and_submissions[2].last.submissions.last

ontology_acronym1 = ontologies_and_submissions[1].first
ontology_acronym2 = ontologies_and_submissions[1].last

submission1.bring(*OntologySubmission.agents_attrs)
submission2.bring(*OntologySubmission.agents_attrs)

# To insure that we don't have duplicated agents in the response
agent_syphax = _create_agent(name: 'Syphax', type: 'person')

submission1.publisher = [_create_agent(name: 'Bilel', type: 'person'), agent_syphax]
submission1.hasContributor = [_create_agent(name: 'Clement', type: 'person'), agent_syphax]

submission2.publisher = [_create_agent(name: 'Imad', type: 'person'), _create_agent(name: 'Serine', type: 'person')]

submission1.save
submission2.save


get "/ontologies/#{ontology_acronym1}/agents"

response = MultiJson.load(last_response.body)
assert_equal response.length, 3
response.each do |r|
assert_includes ['Bilel', 'Syphax', 'Clement'], r["name"]
end

get "/ontologies/#{ontology_acronym2}/agents"

response = MultiJson.load(last_response.body)
assert_equal response.length, 2
response.each do |r|
assert_includes ['Imad', 'Serine'], r["name"]
end
end

private
Expand Down

0 comments on commit 8d47007

Please sign in to comment.