diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-06-19 10:39:44 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-06-19 10:39:44 +0100 |
| commit | dffec2542092df6f207300d5aaca49fcfe7be486 (patch) | |
| tree | 5b6650cb55e2943c2f0b08b166f28ce2daa74095 /tests | |
| parent | deeb507bfd23d4b547f49332ce216ff14db4308c (diff) | |
Change interface so that different formats are more easily handled
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/jq_tests.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/tests/jq_tests.py b/tests/jq_tests.py index 0442459..348727c 100644 --- a/tests/jq_tests.py +++ b/tests/jq_tests.py @@ -1,13 +1,13 @@ from nose.tools import istest, assert_equal -import jq +from jq import jq @istest def dot_operator_does_nothing(): assert_equal( "42", - jq.string_to_string(".", "42") + str(jq(".").transform_string("42")) ) @@ -15,7 +15,7 @@ def dot_operator_does_nothing(): def can_add_one_to_each_element_of_an_array(): assert_equal( "[2,3,4]", - jq.string_to_string("[.[]+1]", "[1,2,3]") + str(jq("[.[]+1]").transform_string("[1,2,3]")) ) @@ -23,13 +23,29 @@ def can_add_one_to_each_element_of_an_array(): def output_elements_are_separated_by_newlines(): assert_equal( "1\n2\n3", - jq.string_to_string(".[]", "[1,2,3]") + str(jq(".[]").transform_string("[1,2,3]")) ) @istest def string_to_json_parses_json_output(): assert_equal( - [1, 2, 3], - jq.string_to_json("[.[]]", "[1,2,3]") + [2, 3, 4], + jq("[.[]+1]").transform_string("[1,2,3]").json() + ) + + +@istest +def string_to_json_parses_json_output(): + assert_equal( + [2, 3, 4], + jq(".[]+1").transform_string("[1,2,3]").json_all() + ) + + +@istest +def output_elements_are_separated_by_newlines_when_there_are_multiple_inputs(): + assert_equal( + "2\n3\n4", + str(jq(".+1").transform_string("1\n2\n3")) ) |
