Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Add JSON tests to testing suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey Kuhlman committed Jul 14, 2013
1 parent de410cb commit b7011c5
Show file tree
Hide file tree
Showing 31 changed files with 60 additions and 38 deletions.
28 changes: 26 additions & 2 deletions test/test_legal_markdown_to_markdown.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! ruby
require 'test/unit'
require 'tempfile'
require 'json'
require 'legal_markdown'

class TestLegalMarkdownToMarkdown < Test::Unit::TestCase
Expand Down Expand Up @@ -39,13 +40,36 @@ def destroy_temp ( temp_file )
File.delete temp_file if File::exists?(temp_file)
end

def test_files
def the_content ( hash )
hash["nodes"].each_value.collect{|v| v["data"]["content"] if v["data"] && v["data"]["content"]}.select{|v| v}
end

def test_markdown_files
puts "\n\nTesting lmd to markdown files.\n\n"
@lmdfiles.each do | lmd_file |
puts "Testing => #{lmd_file}"
temp_file = create_temp
benchmark_file = File.basename(lmd_file, ".lmd") + ".md"
LegalToMarkdown.parse_markdown( [ lmd_file, temp_file ] )
assert_equal(get_file(benchmark_file), get_file(temp_file), "This file threw an exception => #{benchmark_file}")
assert_equal(get_file(benchmark_file), get_file(temp_file), "This file threw an exception => #{lmd_file}")
destroy_temp temp_file
end
end

def test_json_files
puts "Testing lmd to json files.\n\n"
@lmdfiles.each do | lmd_file |
puts "Testing => #{lmd_file}"
temp_file = create_temp
benchmark_file = File.basename(lmd_file, ".lmd") + ".json"
LegalToMarkdown.parse_jason( [ "--to-json", lmd_file, temp_file ])
benchmark = JSON.parse(IO.read(benchmark_file))
temp = JSON.parse(IO.read(temp_file))
assert_not_equal(benchmark["id"], temp["id"])
assert_equal(benchmark["nodes"]["document"], temp["nodes"]["document"], "This file threw an exception => #{lmd_file}")
assert_equal(benchmark["nodes"].count, temp["nodes"].count, "This file threw an exception => #{lmd_file}")
assert_not_equal(benchmark["nodes"]["content"]["nodes"], temp["nodes"]["content"]["nodes"], "This file threw an exception => #{lmd_file}")
assert_equal(the_content(benchmark), the_content(temp), "This file threw an exception => #{lmd_file}")
destroy_temp temp_file
end
end
Expand Down
1 change: 1 addition & 0 deletions test/tests/00.load_write_no_action.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"282f08f12bb50870496ac8c2be9ff11e","nodes":{"document":{"title":"","abstract":"","views":["content"]},"text:928d1917c3997b0899ca8563ed96922f":{"id":"text:928d1917c3997b0899ca8563ed96922f","type":"text","data":{"content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}},"text:3383388687ef2ae03a5ceef82416dd13":{"id":"text:3383388687ef2ae03a5ceef82416dd13","type":"text","data":{"content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}},"text:a8f7e705ab6d75f95fdd3458178a33b9":{"id":"text:a8f7e705ab6d75f95fdd3458178a33b9","type":"text","data":{"content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}},"content":{"nodes":["text:928d1917c3997b0899ca8563ed96922f","text:3383388687ef2ae03a5ceef82416dd13","text:a8f7e705ab6d75f95fdd3458178a33b9"]}}}
21 changes: 3 additions & 18 deletions test/tests/00.load_write_no_action.lmd
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
21 changes: 3 additions & 18 deletions test/tests/00.load_write_no_action.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
1 change: 1 addition & 0 deletions test/tests/01.load_partial_no_action.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"2553d0f902bf59e7b642a6d4413f2db1","nodes":{"document":{"title":"","abstract":"","views":["content"]},"text:9d37a43fc1b8c373d6034bad151301a8":{"id":"text:9d37a43fc1b8c373d6034bad151301a8","type":"text","data":{"content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"}},"text:c671dfc3ca22d18a18d2046702b1ac60":{"id":"text:c671dfc3ca22d18a18d2046702b1ac60","type":"text","data":{"content":"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,"}},"text:c12c1fa9f7a7eca933969f918f53243f":{"id":"text:c12c1fa9f7a7eca933969f918f53243f","type":"text","data":{"content":"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo"}},"text:292d7a1b7dfbd54034081bbd313b2ddd":{"id":"text:292d7a1b7dfbd54034081bbd313b2ddd","type":"text","data":{"content":"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse"}},"text:d53c86ab214628b263b509d462296dca":{"id":"text:d53c86ab214628b263b509d462296dca","type":"text","data":{"content":"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non"}},"text:4eb84a47865cd813c3854d6919e1b26a":{"id":"text:4eb84a47865cd813c3854d6919e1b26a","type":"text","data":{"content":"proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}},"text:7fa64a3a93e40905fba215f3c9357f6f":{"id":"text:7fa64a3a93e40905fba215f3c9357f6f","type":"text","data":{"content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"}},"text:23c8d9a67e77ce63aecc6ccdf059e2ff":{"id":"text:23c8d9a67e77ce63aecc6ccdf059e2ff","type":"text","data":{"content":"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,"}},"text:90838ace26bc214f7d98a98123b35856":{"id":"text:90838ace26bc214f7d98a98123b35856","type":"text","data":{"content":"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo"}},"text:15a9a397935a119b9f1aae6a95cb5ac1":{"id":"text:15a9a397935a119b9f1aae6a95cb5ac1","type":"text","data":{"content":"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse"}},"text:8c3054296c0caaed2f4682fb2eaea4de":{"id":"text:8c3054296c0caaed2f4682fb2eaea4de","type":"text","data":{"content":"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non"}},"text:fe1ff1f849bc8cde410f7efa06aa2d74":{"id":"text:fe1ff1f849bc8cde410f7efa06aa2d74","type":"text","data":{"content":"proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}},"text:8877fad25990f3114cdb00d969f04dfb":{"id":"text:8877fad25990f3114cdb00d969f04dfb","type":"text","data":{"content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"}},"text:64af3e61a0b52122c272d26988525127":{"id":"text:64af3e61a0b52122c272d26988525127","type":"text","data":{"content":"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,"}},"text:41ab44b98a2be8356ddd4996ae6138ea":{"id":"text:41ab44b98a2be8356ddd4996ae6138ea","type":"text","data":{"content":"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo"}},"text:f171c1848f2b64a018a3cad89fc415cb":{"id":"text:f171c1848f2b64a018a3cad89fc415cb","type":"text","data":{"content":"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse"}},"text:a70badb00de1dd5b5bf4f2ed09084cb9":{"id":"text:a70badb00de1dd5b5bf4f2ed09084cb9","type":"text","data":{"content":"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non"}},"text:db82df06d7e5ad4b736a64ca469219b9":{"id":"text:db82df06d7e5ad4b736a64ca469219b9","type":"text","data":{"content":"proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}},"text:2dfcfd2c52ea5e32f2c1ecd2007b73f6":{"id":"text:2dfcfd2c52ea5e32f2c1ecd2007b73f6","type":"text","data":{"content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"}},"text:e64fed92061cf61b88a65d0d82b2d77f":{"id":"text:e64fed92061cf61b88a65d0d82b2d77f","type":"text","data":{"content":"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,"}},"text:322b4fd54a084aeeee72e39cfcdef9c3":{"id":"text:322b4fd54a084aeeee72e39cfcdef9c3","type":"text","data":{"content":"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo"}},"text:2d04459ed9603d8f84d4773ce6373744":{"id":"text:2d04459ed9603d8f84d4773ce6373744","type":"text","data":{"content":"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse"}},"text:2876291ed5512eccffeaef65ece879d0":{"id":"text:2876291ed5512eccffeaef65ece879d0","type":"text","data":{"content":"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non"}},"text:89f1e579ec38c2545a57e208badf4dfe":{"id":"text:89f1e579ec38c2545a57e208badf4dfe","type":"text","data":{"content":"proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}},"content":{"nodes":["text:9d37a43fc1b8c373d6034bad151301a8","text:c671dfc3ca22d18a18d2046702b1ac60","text:c12c1fa9f7a7eca933969f918f53243f","text:292d7a1b7dfbd54034081bbd313b2ddd","text:d53c86ab214628b263b509d462296dca","text:4eb84a47865cd813c3854d6919e1b26a","text:7fa64a3a93e40905fba215f3c9357f6f","text:23c8d9a67e77ce63aecc6ccdf059e2ff","text:90838ace26bc214f7d98a98123b35856","text:15a9a397935a119b9f1aae6a95cb5ac1","text:8c3054296c0caaed2f4682fb2eaea4de","text:fe1ff1f849bc8cde410f7efa06aa2d74","text:8877fad25990f3114cdb00d969f04dfb","text:64af3e61a0b52122c272d26988525127","text:41ab44b98a2be8356ddd4996ae6138ea","text:f171c1848f2b64a018a3cad89fc415cb","text:a70badb00de1dd5b5bf4f2ed09084cb9","text:db82df06d7e5ad4b736a64ca469219b9","text:2dfcfd2c52ea5e32f2c1ecd2007b73f6","text:e64fed92061cf61b88a65d0d82b2d77f","text:322b4fd54a084aeeee72e39cfcdef9c3","text:2d04459ed9603d8f84d4773ce6373744","text:2876291ed5512eccffeaef65ece879d0","text:89f1e579ec38c2545a57e208badf4dfe"]}}}
Loading

0 comments on commit b7011c5

Please sign in to comment.