-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5192 - Add tests for both ruby and python
``` The following tests FAILED: 3705 - RubyTest-SwigJson_Test-swig_json_special_chars (Failed) 3870 - CLITest-SwigJson_Test-swig_json_special_chars (Failed) ```
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pathlib import Path | ||
|
||
import openstudio | ||
|
||
|
||
def test_swig_json_special_chars(): | ||
workflow = openstudio.WorkflowJSON() | ||
runner = openstudio.measure.OSRunner(workflow) | ||
|
||
step1 = openstudio.MeasureStep("MeasureName1") | ||
step1.setArgument("Argument1", 100) | ||
|
||
workflow_step_result1 = openstudio.WorkflowStepResult() | ||
workflow_step_result1.setMeasureName("measure_name_1") | ||
|
||
name = "name_(|)'*$£*µ%é" | ||
val = "val_(|)'*$£*µ%é" | ||
stepValue1 = openstudio.WorkflowStepValue(name, val) | ||
assert name == stepValue1.name() | ||
assert val == stepValue1.valueAsString() | ||
assert val == stepValue1.valueAsJSON() | ||
|
||
workflow_step_result1.addStepValue(stepValue1) | ||
|
||
workflow_step_result1.setStepResult(openstudio.StepResult('Success')) | ||
workflow_step_result1.setCompletedAt(openstudio.DateTime.nowUTC()) | ||
step1.setResult(workflow_step_result1) | ||
|
||
workflow.setWorkflowSteps([step1]) | ||
|
||
d = runner.getPastStepValuesForMeasure("MeasureName1") | ||
assert len(d) == 1 | ||
k, v = next(iter(d.items())) | ||
assert k == name | ||
assert v == val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
######################################################################################################################## | ||
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. | ||
# See also https://openstudio.net/license | ||
######################################################################################################################## | ||
|
||
require 'openstudio' | ||
require 'minitest/autorun' | ||
|
||
class SwigJSONTest < Minitest::Test | ||
|
||
def test_swig_json_special_chars | ||
workflow = OpenStudio::WorkflowJSON.new() | ||
runner = OpenStudio::Measure::OSRunner.new(workflow) | ||
|
||
step1 = OpenStudio::MeasureStep.new("MeasureName1") | ||
step1.setArgument("Argument1", 100) | ||
|
||
workflow_step_result1 = OpenStudio::WorkflowStepResult.new() | ||
workflow_step_result1.setMeasureName("measure_name_1") | ||
|
||
name = "name_(|)'*$£*µ%é" | ||
val = "val_(|)'*$£*µ%é" | ||
stepValue1 = OpenStudio::WorkflowStepValue.new(name, val) | ||
assert_equal(name, stepValue1.name) | ||
assert_equal(val, stepValue1.valueAsString) | ||
assert_equal(val, stepValue1.valueAsJSON) | ||
workflow_step_result1.addStepValue(stepValue1) | ||
|
||
workflow_step_result1.setStepResult('Success'.to_StepResult) | ||
workflow_step_result1.setCompletedAt(OpenStudio::DateTime.nowUTC()) | ||
step1.setResult(workflow_step_result1) | ||
|
||
workflow.setWorkflowSteps([step1]) | ||
|
||
# workflow.saveAs("OSRunner_getPastStepValues_special_chars.osw") | ||
|
||
h = runner.getPastStepValuesForMeasure("MeasureName1") | ||
assert_equal(1, h.size) | ||
assert_equal(name.to_sym, h.keys.first) | ||
assert_equal(val, h.values.first) | ||
end | ||
|
||
end |