Skip to content
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 lib/ontologies_linked_data/utils/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.gzip?(file_path)
raise ArgumentError, "File path #{file_path} not found" unless File.exist? file_path

file_type = `file --mime -b #{Shellwords.escape(file_path)}`
file_type.split(';')[0] == 'application/x-gzip'
file_type.split(';')[0] == 'application/gzip'
end

def self.files_from_zip(file_path)
Expand Down
Binary file added test/data/ontology_files/BRO_v3.2.owl.gz
Binary file not shown.
42 changes: 42 additions & 0 deletions test/models/test_ontology_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ def test_automaster_from_zip
assert_equal nil, LinkedData::Utils::FileHelpers.automaster(zipfile, ".obo")
end

def test_is_gzip
gzipfile = "./test/data/ontology_files/BRO_v3.2.owl.gz"
zipfile = "./test/data/ontology_files/evoc_v2.9.zip"
assert LinkedData::Utils::FileHelpers.gzip?(gzipfile)
refute LinkedData::Utils::FileHelpers.gzip?(zipfile)
end

def test_duplicated_file_names

acronym = "DUPTEST"
Expand Down Expand Up @@ -501,6 +508,41 @@ def test_submission_parse_zip
puts "#{ctr} classes with no label"
end

def test_submission_parse_gzip
skip if ENV["BP_SKIP_HEAVY_TESTS"] == "1"

acronym = "BROGZ"
name = "BRO GZIPPED"
ontologyFile = "./test/data/ontology_files/BRO_v3.2.owl.gz"
id = 11

LinkedData::TestCase.backend_4s_delete

ont_submision = LinkedData::Models::OntologySubmission.new({submissionId: id})
refute ont_submision.valid?
assert_equal 4, ont_submision.errors.length
uploadFilePath = LinkedData::Models::OntologySubmission.copy_file_repository(acronym, id, ontologyFile)
ont_submision.uploadFilePath = uploadFilePath
owl, bro, user, contact = submission_dependent_objects("OWL", acronym, "test_linked_models", name)
ont_submision.released = DateTime.now - 4
ont_submision.hasOntologyLanguage = owl
ont_submision.prefLabelProperty = RDF::URI.new("http://bioontology.org/projects/ontologies/radlex/radlexOwl#Preferred_name")
ont_submision.ontology = bro
ont_submision.contact = [contact]
assert ont_submision.valid?
ont_submision.save
parse_options = {process_rdf: true, reasoning: true, index_search: false, run_metrics: false, diff: false}
begin
tmp_log = Logger.new(TestLogFile.new)
ont_submision.process_submission(tmp_log, parse_options)
rescue StandardError => e
puts "Error, logged in #{tmp_log.instance_variable_get("@logdev").dev.path}"
raise e
end

assert ont_submision.ready?({status: [:uploaded, :rdf, :rdf_labels]})
end

def test_download_ontology_file
begin
server_port = Random.rand(55000..65535) # http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Dynamic.2C_private_or_ephemeral_ports
Expand Down