Skip to content

Commit

Permalink
Fix failing job test
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Jan 8, 2025
1 parent b9a3252 commit 21f1e53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions lib/seek/isa_templates/template_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def self.valid_isa_json?(json)
end

def self.get_sample_attribute_type(title)
sa = SampleAttributeType.find_by(title:)
sa = SampleAttributeType.find_by(title: title)
@errors.append "<li>Could not find a Sample Attribute Type named '#{title}'</li>" if sa.nil?

return if sa.nil?
Expand All @@ -187,10 +187,10 @@ def self.get_sample_attribute_type(title)
def self.get_isa_tag_id(title)
return nil if title.blank?

it = IsaTag.find_by(title:)
it = IsaTag.find_by(title: title)
@errors.append "<li>Could not find an ISA Tag named '#{title}'</li>" if it.nil?

it.id
it&.id
end

def self.seed_isa_tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"iri": null,
"name": "Source Name",
"description": "Sources are considered as the starting biological material used in a study.",
"dataType": "String attribute type 1",
"dataType": "String",
"title": true,
"required": true,
"isaTag": "source"
Expand All @@ -29,7 +29,7 @@
"iri": null,
"name": "Source Characteristic 1",
"description": "A characteristic of the source.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand Down Expand Up @@ -57,15 +57,15 @@
"iri": null,
"name": "Input",
"description": "Registered Samples in the platform used as input for this protocol.",
"dataType": "Sample multi attribute type 1",
"dataType": "Registered Sample List",
"required": true,
"isaTag": null
},
{
"iri": null,
"name": "Name of a protocol with samples as outputs",
"description": "Type of experimental step that generates samples as outputs from the study sources.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand All @@ -75,7 +75,7 @@
"iri": null,
"name": "Name of protocol parameter 1",
"description": "A parameter for the protocol.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand All @@ -85,7 +85,7 @@
"iri": null,
"name": "Sample Name",
"description": "Samples are considered as biological material sampled from sources and used in the study.",
"dataType": "String attribute type 1",
"dataType": "String",
"title": true,
"required": true,
"isaTag": "sample"
Expand All @@ -94,7 +94,7 @@
"iri": null,
"name": "Sample Characteristic 1",
"description": "A characteristic of the sample.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand Down Expand Up @@ -122,15 +122,15 @@
"iri": null,
"name": "Input",
"description": "Registered Samples in the platform used as input for this protocol.",
"dataType": "Sample multi attribute type 1",
"dataType": "Registered Sample List",
"required": true,
"isaTag": null
},
{
"iri": null,
"name": "Name of a protocol with material output",
"description": "Type of assay or experimental step performed that generates a material output.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand All @@ -140,7 +140,7 @@
"iri": null,
"name": "Name of protocol parameter 1",
"description": "A parameter for the protocol.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand All @@ -150,7 +150,7 @@
"iri": null,
"name": "Output material Name",
"description": "Name of the major material output resulting from the application of the protocol.",
"dataType": "String attribute type 1",
"dataType": "String",
"title": true,
"required": true,
"isaTag": "other_material"
Expand All @@ -159,7 +159,7 @@
"iri": null,
"name": "Output material characteristic 1",
"description": "Characteristic 1 of the output material.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand Down Expand Up @@ -187,15 +187,15 @@
"iri": null,
"name": "Input",
"description": "Registered Samples in the platform used as input for this protocol.",
"dataType": "Sample multi attribute type 1",
"dataType": "Registered Sample List",
"required": true,
"isaTag": null
},
{
"iri": null,
"name": "Name of a protocol with data file output",
"description": "Type of assay or experimental step performed that generates a data file output.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand All @@ -205,7 +205,7 @@
"iri": null,
"name": "Name of protocol parameter 1",
"description": "A parameter for the protocol.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand All @@ -215,7 +215,7 @@
"iri": null,
"name": "Data file Name",
"description": "Name of the major data file output resulting from the application of the protocol.",
"dataType": "String attribute type 1",
"dataType": "String",
"title": true,
"required": true,
"isaTag": "data_file"
Expand All @@ -224,7 +224,7 @@
"iri": null,
"name": "Data file characteristic 1",
"description": "Characteristic 1 of the data file output.",
"dataType": "String attribute type 1",
"dataType": "String",
"required": true,
"ontology": null,
"CVList": null,
Expand Down
11 changes: 6 additions & 5 deletions test/unit/jobs/populate_templates_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class PopulateTemplatesJobTest < ActiveSupport::TestCase
def setup
# Create the SampleAttributeTypes
# The title MUST be set manually!
FactoryBot.create(:string_sample_attribute_type, title: 'String attribute type 1')
FactoryBot.create(:sample_multi_sample_attribute_type, title: 'Sample multi attribute type 1')
FactoryBot.create(:string_sample_attribute_type, title: 'String') if SampleAttributeType.find_by(title: 'String').nil?
FactoryBot.create(:sample_multi_sample_attribute_type, title: 'Registered Sample List') if SampleAttributeType.find_by(title: 'Registered Sample List').nil?

# Create the ISA Tags
%i[source_isa_tag sample_isa_tag protocol_isa_tag source_characteristic_isa_tag sample_characteristic_isa_tag
Expand All @@ -16,6 +16,7 @@ def setup

# Set isa_json_compliance_enabled to true
Seek::Config.isa_json_compliance_enabled = true
@admin = FactoryBot.create(:admin)
end

def teardown
Expand All @@ -31,7 +32,7 @@ def teardown

assert_nothing_raised do
assert_difference('Template.count', 4) do
PopulateTemplatesJob.perform_now
PopulateTemplatesJob.perform_now(@admin)
end
end
end
Expand All @@ -44,8 +45,8 @@ def teardown

assert_no_difference('Template.count') do
assert_raises(RuntimeError,
'<ul><li>The property \'#/data/0/data/1/dataType\' value \"Invalid String attribute type 1\" did not match one of the following values: String attribute type 1, Sample multi attribute type 1 in schema file:///home/kepel/projects/seek/lib/seek/isa_templates/template_attributes_schema_test.json#</li><li>Could not find a Sample Attribute Type named \'Invalid String attribute type 1\'</li></ul>') do
PopulateTemplatesJob.perform_now
'<ul><li>The property \'#/data/0/data/1/dataType\' value \"Invalid String attribute type 1\" did not match one of the following values: ') do
PopulateTemplatesJob.perform_now(@admin)
end
end
end
Expand Down

0 comments on commit 21f1e53

Please sign in to comment.