Class: Crucible::Tests::TestScriptEngine
- Inherits:
-
Object
- Object
- Crucible::Tests::TestScriptEngine
- Defined in:
- lib/tests/testscripts/testscript_engine.rb
Constant Summary collapse
- @@models =
[]
Class Method Summary collapse
Instance Method Summary collapse
- #execute_all ⇒ Object
- #find_test(key) ⇒ Object
-
#initialize(client = nil, client2 = nil) ⇒ TestScriptEngine
constructor
A new instance of TestScriptEngine.
- #load_testscripts ⇒ Object
- #tests ⇒ Object
Constructor Details
#initialize(client = nil, client2 = nil) ⇒ TestScriptEngine
Returns a new instance of TestScriptEngine.
7 8 9 10 11 12 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 7 def initialize(client=nil, client2=nil) @client = client @client2 = client2 @scripts = [] load_testscripts end |
Class Method Details
.list_all(metadata = false) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 32 def self.list_all(=false) list = {} # TODO: Determine if we need resource-based testscript listing support TestScriptEngine.new.tests.each do |test| list[test.title] = {} BaseTest::JSON_FIELDS.each {|field| list[test.title][field] = test.send(field)} if = test.(true) BaseTest::METADATA_FIELDS.each do |field| field_hash = {} .each { |tm| field_hash[tm[:test_method]] = tm[field] } list[test.title][field] = field_hash end end end list end |
.parse_testscript_xml ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 57 def self.parse_testscript_xml return unless @@models.empty? # get all TestScript's in testscripts/xml root = File. '.', File.dirname(File.absolute_path(__FILE__)) files = File.join(root, 'xml', '**/*.xml') Dir.glob(files).each do |f| next if f.include? "/_reference/" # to support connectathon11 fixtures; review if there is a better way next if f.include? "Track11-SDC" # uses STU3 models next if f.include? "Track3-CDS-on-FHIR" # uses STU3 models next if f.include? "Track9-Patch" # uses Patch next if f.include? "Track6-FHIR-Genomics" # uses STU3 models #TODO: these can be finished with DSTU2 next if f.include? "Track2-Terminology" next if f.include? "Track7-LabOrderLabReport" @@models << FHIR::TestScript.from_xml( File.read(f) ) end end |
Instance Method Details
#execute_all ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 22 def execute_all results = {} self.tests.each do |test| # TODO: Do we want to separate out multiserver tests? next if test.multiserver results.merge! test.execute end results end |
#find_test(key) ⇒ Object
18 19 20 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 18 def find_test(key) @scripts.find{|s| s.id == key || s.title == key} || [] end |
#load_testscripts ⇒ Object
50 51 52 53 54 55 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 50 def load_testscripts return unless @scripts.empty? @@models.each do |model| @scripts << BaseTestScript.new(model, @client, @client2) end end |
#tests ⇒ Object
14 15 16 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 14 def tests @scripts end |