PageRenderTime 26ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/storyteller/test/story_teller_test.rb

http://multimedia-storyteller.googlecode.com/
Ruby | 661 lines | 441 code | 147 blank | 73 comment | 15 complexity | a219326d8f3c5db187458f3b35ca34fa MD5 | raw file
Possible License(s): LGPL-2.1
  1. require 'test/unit'
  2. require 'test/test_case'
  3. require 'story_teller'
  4. class StoryTellerTest < Test::Unit::TestCase
  5. def setup
  6. FileUtils.mkdir("data")
  7. FileUtils.mkdir("data/mytrip")
  8. FileUtils.mkdir("data/yourtrip")
  9. FileUtils.mkdir("data/ourtrip")
  10. FileUtils.mkdir("data2")
  11. FileUtils.mkdir("data2/mytrip2")
  12. FileUtils.cp("test/art.jpg","data/mytrip/1.jpg")
  13. FileUtils.cp("test/dog.jpg","data/mytrip/2.jpg")
  14. FileUtils.cp("test/art.jpg","data2/mytrip2/Picture 001.jpg")
  15. FileUtils.cp("test/dog.jpg","data2/mytrip2/Picture 002.jpg")
  16. FileUtils.mkdir("root")
  17. FileUtils.mkdir("root/one")
  18. FileUtils.mkdir("root/two")
  19. FileUtils.mkdir("root/three")
  20. FileUtils.mkdir("tmp_dir")
  21. File.open("root/one/a.txt","a") { |file| file.puts "1" }
  22. File.open("root/one/b.txt","a") { |file| file.puts "12" }
  23. File.open("root/one/c.txt","a") { |file| file.puts "123" }
  24. File.open("root/two/d.txt","a") { |file| file.puts "1234" }
  25. File.open("root/two/e.txt","a") { |file| file.puts "12345" }
  26. File.open("root/three/f.txt","a") { |file| file.puts "123456" }
  27. File.open("root/three/g.txt","a") { |file| file.puts "1234567" }
  28. File.open("root/three/h.txt","a") { |file| file.puts "12345678" }
  29. File.open("myflash.grin","a") { |file| file.puts "" }
  30. Help.display_level = Help::QUIET_LEVEL
  31. @story = StoryTeller.new("tmp_dir")
  32. @story.assign_home
  33. end
  34. def teardown
  35. FileUtils.rm_rf("data")
  36. FileUtils.rm_rf("data2")
  37. FileUtils.rm_rf("root")
  38. FileUtils.rm_rf("tmp_dir") if File.exist? "tmp_dir"
  39. FileUtils.rm_rf("blah") if File.exist? "blah"
  40. FileUtils.rm(".properties") if File.exist? ".properties"
  41. FileUtils.rm_rf("empty_dir") if File.exist? "empty_dir"
  42. FileUtils.rm("myflash.grin") if File.exist? "myflash.grin"
  43. FileUtils.rm("myflash.swf") if File.exist? "myflash.swf"
  44. FileUtils.rm("myflash.smil") if File.exist? "myflash.smil"
  45. FileUtils.rm("myflash.blah") if File.exist? "myflash.blah"
  46. FileUtils.rm("movie.swf") if File.exist? "movie.swf"
  47. FileUtils.rm("movie.grin") if File.exist? "movie.grin"
  48. FileUtils.rm("movie.smil") if File.exist? "movie.smil"
  49. FileUtils.rm("blah.blah.swf") if File.exist? "blah.blah.swf"
  50. FileUtils.rm("blah.blah.smil") if File.exist? "blah.blah.smil"
  51. FileUtils.rm("blah.swf") if File.exist? "blah.swf"
  52. FileUtils.rm("blah.smil") if File.exist? "blah.smil"
  53. end
  54. def test_constructor_no_properties
  55. story = StoryTeller.new("blah")
  56. assert_equal false, story.valid?
  57. end
  58. def test_constructor_default
  59. File.open(".properties","a") { |file| file.puts "" }
  60. story = StoryTeller.new
  61. assert_equal true, story.valid?
  62. end
  63. def test_constructor_non_default
  64. story = StoryTeller.new("tmp_dir")
  65. assert_equal true, story.valid?
  66. end
  67. def test_assign_home
  68. story = StoryTeller.new("blah")
  69. assert_equal false, story.valid?
  70. story.assign_home
  71. assert_equal true, story.valid?
  72. assert_equal true, File.exist?("blah/.properties")
  73. end
  74. def test_assign_home_sets_flickr_data
  75. story = StoryTeller.new("blah")
  76. story.assign_home
  77. fa = FileAnalyser.new
  78. fa.load_config("blah/.properties")
  79. assert_equal 'f664bcb86468af50ff33c228b385eb59', fa.property_of("flickr_api_key")
  80. assert_equal 'dc74f2f7693d245a', fa.property_of("flickr_shared_secret")
  81. end
  82. def test_assign_home_do_not_overwrite
  83. FileUtils.rm("tmp_dir/.properties")
  84. File.open("tmp_dir/.properties","a") { |infile| infile.puts "aha" }
  85. st = StoryTeller.new("tmp_dir")
  86. assert true, File.exists?("tmp_dir/.properties")
  87. File.open("tmp_dir/.properties","r") do |infile|
  88. assert_equal "aha\n", infile.gets
  89. assert_nil infile.gets
  90. end
  91. end
  92. def test_add_media_saves_to_config
  93. @story.add_media "", "data"
  94. assert_equal ["data"], @story.media_directories
  95. fa = FileAnalyser.new
  96. fa.load_config("tmp_dir/.properties")
  97. assert_equal "data", fa.property_of("media_directory")
  98. end
  99. def test_add_media_has_name
  100. @story.add_media "Disk1", "root"
  101. assert_equal true, File.exist?("tmp_dir/Disk1/one")
  102. assert_equal true, File.exist?("tmp_dir/Disk1/two")
  103. assert_equal true, File.exist?("tmp_dir/Disk1/.dir")
  104. assert_equal true, File.exist?("tmp_dir/Disk1/one/.dir")
  105. assert_equal true, File.exist?("tmp_dir/Disk1/two/.dir")
  106. assert_equal true, File.exist?("tmp_dir/Disk1/one/a.txt")
  107. assert_equal true, File.exist?("tmp_dir/Disk1/one/b.txt")
  108. assert_equal true, File.exist?("tmp_dir/Disk1/one/c.txt")
  109. assert_equal true, File.exist?("tmp_dir/Disk1/two/d.txt")
  110. assert_equal true, File.exist?("tmp_dir/Disk1/two/e.txt")
  111. end
  112. def test_add_media_no_name
  113. @story.add_media "", "root"
  114. assert_equal true, File.exist?("tmp_dir/one")
  115. assert_equal true, File.exist?("tmp_dir/two")
  116. assert_equal true, File.exist?("tmp_dir/.dir")
  117. assert_equal true, File.exist?("tmp_dir/one/.dir")
  118. assert_equal true, File.exist?("tmp_dir/two/.dir")
  119. assert_equal true, File.exist?("tmp_dir/one/a.txt")
  120. assert_equal true, File.exist?("tmp_dir/one/b.txt")
  121. assert_equal true, File.exist?("tmp_dir/one/c.txt")
  122. assert_equal true, File.exist?("tmp_dir/two/d.txt")
  123. assert_equal true, File.exist?("tmp_dir/two/e.txt")
  124. end
  125. def test_add_media_check_properties
  126. @story.add_media "", "root"
  127. assert_equal true, File.exist?("tmp_dir/.dir")
  128. assert_equal true, File.exist?("tmp_dir/one")
  129. assert_equal true, File.exist?("tmp_dir/one/.dir")
  130. assert_equal true, File.exist?("tmp_dir/one/a.txt")
  131. fa = FileAnalyser.new
  132. fa.load_config "tmp_dir/.dir"
  133. assert_equal "root", fa.property_of("path")
  134. fa.load_config "tmp_dir/one/.dir"
  135. assert_equal "root\\one", fa.property_of("path")
  136. fa.load_config "tmp_dir/one/a.txt"
  137. assert_equal "root\\one/a.txt", fa.property_of("path")
  138. end
  139. def test_path_of
  140. @story.add_media "", "root"
  141. assert_equal true, File.exist?("tmp_dir/.dir")
  142. assert_equal true, File.exist?("tmp_dir/one")
  143. assert_equal true, File.exist?("tmp_dir/one/.dir")
  144. assert_equal true, File.exist?("tmp_dir/one/a.txt")
  145. assert_equal "root", @story.path_of("tmp_dir")
  146. assert_equal "root\\one", @story.path_of("tmp_dir/one")
  147. assert_equal "root\\one", @story.path_of("tmp_dir/one/")
  148. assert_equal "root\\one/a.txt", @story.path_of("tmp_dir/one/a.txt")
  149. fa = FileAnalyser.new
  150. assert_equal "root", FileAnalyser.path_of("tmp_dir")
  151. assert_equal "root\\one", FileAnalyser.path_of("tmp_dir/one")
  152. assert_equal "root\\one", FileAnalyser.path_of("tmp_dir/one/")
  153. assert_equal "root\\one/a.txt", FileAnalyser.path_of("tmp_dir/one/a.txt")
  154. end
  155. def test_add_media_ignore_as_required
  156. @story.ignore "mytrip"
  157. @story.ignore "yourtrip"
  158. backup = @story.add_media "", "data"
  159. assert_equal_one_of "/ourtrip", "\\ourtrip", backup.directories[0]
  160. end
  161. def test_ignore_default_dotDir
  162. assert_equal [".dir"], @story.ignoring
  163. end
  164. def test_ignore
  165. @story.ignore "abc"
  166. assert_equal ["abc",".dir"], @story.ignoring
  167. assert_equal Help::IGNORE, @story.all_help[0].id
  168. fa = FileAnalyser.new
  169. fa.load_config("tmp_dir/.properties")
  170. assert_equal ["abc"], fa.properties_of("ignore")
  171. end
  172. def test_parse_nothing
  173. @story.parse nil
  174. @story.parse []
  175. end
  176. def test_parse_add_media
  177. @story.parse "add data".split
  178. assert_equal ["data"], @story.media_directories
  179. assert_equal Help::BACKUP, @story.all_help[0].id
  180. end
  181. def test_parse_add_media_stores_data
  182. @story.parse "add data".split
  183. assert_equal true, File.exist?("tmp_dir/mytrip")
  184. assert_equal true, File.exist?("tmp_dir/yourtrip")
  185. assert_equal true, File.exist?("tmp_dir/ourtrip")
  186. end
  187. def test_parse_add_media_include_root_dir
  188. @story.parse "add root/one".split
  189. assert_equal true, File.exist?("tmp_dir/a.txt")
  190. assert_equal true, File.exist?("tmp_dir/b.txt")
  191. assert_equal true, File.exist?("tmp_dir/c.txt")
  192. end
  193. def test_parse_add_media_specify_directory
  194. @story.parse "add myone root/one".split
  195. assert_equal true, File.exist?("tmp_dir/myone/a.txt")
  196. assert_equal true, File.exist?("tmp_dir/myone/b.txt")
  197. assert_equal true, File.exist?("tmp_dir/myone/c.txt")
  198. end
  199. def test_parse_add_unknown_directory
  200. @story.parse "add /blah".split
  201. assert_equal Help::UNKNOWN_DIRECTORY, @story.all_help[0].id
  202. assert_equal Help::ADD_USAGE, @story.all_help[1].id
  203. end
  204. def test_parse_add_no_directory
  205. @story.parse "add".split
  206. assert_equal Help::NO_DIRECTORY, @story.all_help[0].id
  207. assert_equal Help::ADD_USAGE, @story.all_help[1].id
  208. end
  209. def test_parse_nothing_see_help
  210. story = StoryTeller.new
  211. story.parse "".split
  212. assert_equal Help::NO_REPOSITORY, story.all_help[0].id
  213. assert_equal Help::REPOSITORY_USAGE, story.all_help[1].id
  214. end
  215. def test_parse_ignore
  216. @story.parse "ignore a b c".split
  217. assert_equal Help::IGNORE, @story.all_help[0].id
  218. assert_equal Help::IGNORE, @story.all_help[1].id
  219. assert_equal Help::IGNORE, @story.all_help[2].id
  220. end
  221. def test_parse_no_respository
  222. @story.parse "ignore a b c".split
  223. assert_equal Help::IGNORE, @story.all_help[0].id
  224. assert_equal Help::IGNORE, @story.all_help[1].id
  225. assert_equal Help::IGNORE, @story.all_help[2].id
  226. end
  227. def test_parse_new
  228. @story.parse "new".split
  229. assert_equal true, @story.valid?
  230. assert_equal true, File.exist?("storyteller/.properties")
  231. assert_equal Help::REPOSITORY_CREATED, @story.all_help[0].id
  232. end
  233. def test_parse_new_with_name
  234. @story.parse "new blah".split
  235. assert_equal true, @story.valid?
  236. assert_equal true, File.exist?("blah/.properties")
  237. assert_equal Help::REPOSITORY_CREATED, @story.all_help[0].id
  238. end
  239. def test_parse_tag_root_directory
  240. @story.parse "add root".split
  241. @story.parse ["tag",".","Blah blah blah"]
  242. fa = FileAnalyser.new
  243. fa.load_config "tmp_dir/.dir"
  244. assert_equal "Blah blah blah", fa.property_of("tag")
  245. end
  246. def test_parse_tag_directory
  247. @story.parse "add root".split
  248. @story.parse ["tag","one","More stuff"]
  249. fa = FileAnalyser.new
  250. fa.load_config "tmp_dir/one/.dir"
  251. assert_equal "More stuff", fa.property_of("tag")
  252. end
  253. def test_parse_tag_file
  254. @story.parse "add root".split
  255. @story.parse ["tag","one/a.txt","Still More stuff"]
  256. fa = FileAnalyser.new
  257. fa.load_config "tmp_dir/one/a.txt"
  258. assert_equal "Still More stuff", fa.property_of("tag")
  259. end
  260. def test_parse_tag_file_with_spaces
  261. @story.parse "add data2".split
  262. @story.parse ["tag","mytrip2/Picture 001.jpg","Still More stuff"]
  263. fa = FileAnalyser.new
  264. fa.load_config "tmp_dir/mytrip2/Picture 001.jpg"
  265. assert_equal "Still More stuff", fa.property_of("tag")
  266. end
  267. def test_parse_flickr_no_file
  268. @story.parse "add root".split
  269. @story.parse "flickr".split
  270. assert_equal Help::FLICKR_USAGE, @story.all_help.last.id
  271. end
  272. def test_property_of
  273. @story.parse "add root".split
  274. @story.parse ["tag",".","Blah blah blah"]
  275. @story.parse ["tag","one/a.txt","Still More stuff"]
  276. assert_equal "Blah blah blah", @story.property_of("tmp_dir","tag")
  277. assert_equal "Still More stuff", @story.property_of("tmp_dir/one/a.txt","tag")
  278. assert_equal "Blah blah blah", FileAnalyser.property_of("tmp_dir","tag")
  279. assert_equal "Still More stuff", FileAnalyser.property_of("tmp_dir/one/a.txt","tag")
  280. end
  281. def test_properties_of
  282. @story.parse "add root".split
  283. @story.parse ["tag",".","Blah blah blah"]
  284. @story.parse ["tag","one/a.txt","Still More stuff"]
  285. assert_equal "Blah blah blah", @story.properties_of("tmp_dir","tag").last
  286. assert_equal "Still More stuff", @story.properties_of("tmp_dir/one/a.txt","tag").last
  287. assert_equal "Blah blah blah", FileAnalyser.properties_of("tmp_dir","tag").last
  288. assert_equal "Still More stuff", FileAnalyser.properties_of("tmp_dir/one/a.txt","tag").last
  289. end
  290. def test_parse_compile_no_files
  291. @story.parse "add data".split
  292. @story.parse "compile".split
  293. assert_equal Help::COMPILE_USAGE, @story.all_help.last.id
  294. end
  295. def test_parse_compile_generate_file_smil
  296. @story.parse "compile myflash.grin myflash.blah smil".split
  297. assert_equal true, File.exists?("myflash.blah")
  298. assert_equal false, File.exists?("myflash.swf")
  299. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  300. end
  301. def test_parse_compile_generate_file_flash
  302. @story.parse "compile myflash.grin myflash.blah flash".split
  303. assert_equal false, File.exists?("myflash.smil")
  304. assert_equal true, File.exists?("myflash.blah")
  305. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  306. end
  307. def test_parse_compile_generate_file_only_input_file
  308. @story.parse "compile myflash.grin".split
  309. assert_equal true, File.exists?("myflash.swf")
  310. assert_equal true, File.exists?("myflash.smil")
  311. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  312. end
  313. def test_parse_compile_generate_file_no_type_swf
  314. @story.parse "compile myflash.grin blah.swf".split
  315. assert_equal true, File.exists?("blah.swf")
  316. assert_equal false, File.exists?("blah.smil")
  317. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  318. end
  319. def test_parse_compile_generate_file_no_type_smil
  320. @story.parse "compile myflash.grin blah.smil".split
  321. assert_equal false, File.exists?("blah.swf")
  322. assert_equal true, File.exists?("blah.smil")
  323. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  324. end
  325. def test_parse_compile_generate_file_no_type_unknown
  326. @story.parse "compile myflash.grin blah.blah".split
  327. assert_equal true, File.exists?("blah.blah.swf")
  328. assert_equal true, File.exists?("blah.blah.smil")
  329. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  330. end
  331. def test_parse_compile_generate_file_unknown_extension_and_no_type
  332. @story.parse "compile myflash.grin blah.blah".split
  333. assert_equal true, File.exists?("blah.blah.swf")
  334. assert_equal true, File.exists?("blah.blah.smil")
  335. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  336. end
  337. def test_parse_compile_generate_file_unknown_input_file
  338. @story.parse "compile unknown.grin myflash.swf".split
  339. assert_equal Help::UNKNOWN_FILE, @story.all_help.last.id
  340. end
  341. def test_parse_flash_no_directory
  342. @story.parse "add data".split
  343. @story.parse "flash".split
  344. assert_equal Help::FLASH_USAGE, @story.all_help.last.id
  345. end
  346. def test_parse_flash_unknown_directory
  347. @story.parse "add data".split
  348. @story.parse "flash movie.swf blah".split
  349. assert_equal Help::UNKNOWN_FILE, @story.all_help.last.id
  350. assert_equal false, File.exists?("movie.swf")
  351. end
  352. def test_parse_flash_directory
  353. @story.parse "add data".split
  354. @story.parse ["tag","mytrip","The title"]
  355. @story.parse ["tag","mytrip/1.jpg","A picture"]
  356. @story.parse "flash movie.swf tmp_dir/mytrip".split
  357. assert_equal Help::COMPILE_COMPLETE, @story.all_help.last.id
  358. assert_equal true, File.exists?("movie.grin")
  359. File.open("movie.grin") do |infile|
  360. assert_equal "The title\n", infile.gets
  361. assert_equal "image \"data\\mytrip/2.jpg\"\n", infile.gets
  362. assert_equal "image \"data\\mytrip/1.jpg\" A picture\n", infile.gets
  363. assert_nil infile.gets
  364. end
  365. assert_equal true, File.exists?("movie.swf")
  366. end
  367. def test_freehand_image_with_spaces
  368. @story.parse "add data2".split
  369. @story.parse ["tag","mytrip2","The title"]
  370. @story.parse ["tag","mytrip2/Picture 001.jpg","A picture"]
  371. freehand = Freehand.new(@story,"movie.swf")
  372. freehand.parse nil
  373. freehand.parse "image \"tmp_dir/mytrip2/Picture 001.jpg\""
  374. freehand.parse "image \"tmp_dir/mytrip2/Picture 002.jpg\""
  375. freehand.parse "end"
  376. assert_equal true, File.exists?("movie.grin")
  377. File.open("movie.grin") do |infile|
  378. assert_equal "image \"data2\\mytrip2/Picture 001.jpg\" A picture\n", infile.gets
  379. assert_equal "image \"data2\\mytrip2/Picture 002.jpg\"\n", infile.gets
  380. assert_nil infile.gets
  381. end
  382. end
  383. def test_freehand_realizes_images_from_story
  384. @story.parse "add data".split
  385. @story.parse ["tag","mytrip","The title"]
  386. @story.parse ["tag","mytrip/1.jpg","A picture"]
  387. freehand = Freehand.new(@story,"movie.swf")
  388. freehand.parse nil
  389. freehand.parse "image tmp_dir/mytrip/1.jpg"
  390. freehand.parse "end"
  391. assert_equal true, File.exists?("movie.grin")
  392. File.open("movie.grin") do |infile|
  393. assert_equal "image \"data\\mytrip/1.jpg\" A picture\n", infile.gets
  394. assert_nil infile.gets
  395. end
  396. end
  397. def test_freehand_realizes_images_and_labels_from_story
  398. @story.parse "add data".split
  399. @story.parse ["tag","mytrip","The title"]
  400. @story.parse ["tag","mytrip/1.jpg","A picture"]
  401. freehand = Freehand.new(@story,"movie.swf")
  402. freehand.parse nil
  403. freehand.parse "image tmp_dir/mytrip/1.jpg"
  404. freehand.parse "image tmp_dir/mytrip/1.jpg A better tagged picture"
  405. freehand.parse "image tmp_dir/mytrip/2.jpg Another great picture"
  406. freehand.parse "end"
  407. assert_equal true, File.exists?("movie.grin")
  408. File.open("movie.grin") do |infile|
  409. assert_equal "image \"data\\mytrip/1.jpg\" A picture\n", infile.gets
  410. assert_equal "image \"data\\mytrip/1.jpg\" A better tagged picture\n", infile.gets
  411. assert_equal "image \"data\\mytrip/2.jpg\" Another great picture\n", infile.gets
  412. assert_nil infile.gets
  413. end
  414. end
  415. def test_parse_update_media_nothing
  416. @story.parse "add data".split
  417. @story.parse "update data".split
  418. end
  419. def test_parse_update_media_new_directory
  420. @story.parse "add data".split
  421. FileUtils.mkdir("data/newtrip")
  422. FileUtils.cp("test/art.jpg","data/newtrip/1.jpg")
  423. FileUtils.cp("test/dog.jpg","data/newtrip/2.jpg")
  424. @story.parse "update data".split
  425. assert_equal true, File.exist?("tmp_dir/newtrip")
  426. assert_equal true, File.exist?("tmp_dir/newtrip/1.jpg")
  427. assert_equal true, File.exist?("tmp_dir/newtrip/2.jpg")
  428. end
  429. def test_size
  430. @story.parse "add root".split
  431. assert_equal_one_of 690, 52, @story.size
  432. end
  433. def test_extractFileData()
  434. assert_equal ["",""], StoryTeller.extractFileData("image");
  435. assert_equal ["1.jpg",""], StoryTeller.extractFileData("blah 1.jpg");
  436. assert_equal ["1.jpg","some data"], StoryTeller.extractFileData("image 1.jpg some data");
  437. assert_equal ["Picture 001.jpg",""], StoryTeller.extractFileData("blah \"Picture 001.jpg\"");
  438. assert_equal ["Picture 001.jpg","more data"], StoryTeller.extractFileData("blah \"Picture 001.jpg\" more data");
  439. assert_equal ["Picture 001.jpg","more"], StoryTeller.extractFileData("blah \"Picture 001.jpg\" more");
  440. end
  441. # def test_parse_update_media_removed_directory
  442. # @story.parse "add data".split
  443. #
  444. # FileUtils.rm_rf("data/mytrip")
  445. #
  446. # @story.parse "update data".split
  447. # assert_equal false, File.exist?("tmp_dir/mytrip")
  448. # end
  449. ####################3
  450. #
  451. # changing the backup functionality
  452. #
  453. # def backup(what,where)
  454. # return false unless what == "-all"
  455. #
  456. # number_of_files = 0
  457. # media_directories.each do |media_dir|
  458. # backup_dir = "#{@home}/#{media_dir}"
  459. # Find.find(backup_dir) do |path|
  460. # next if File.directory? path
  461. # next if internal_file? path
  462. #
  463. # number_of_files += 1
  464. # source_file = source_file_for path
  465. # dest_file = destination_file_for path, where
  466. # dest_dir = directory_of(dest_file)
  467. #
  468. # @all_help << Help.backedup_file(source_file, dest_file)
  469. # FileUtils.mkdir_p(dest_dir) unless File.exist? dest_dir
  470. # FileUtils.cp source_file, dest_file
  471. # end
  472. # end
  473. # @all_help << Help.backup_complete(where,number_of_files)
  474. # end
  475. #
  476. # def source_file_for(path)
  477. # start_index = @home.length + "/Disk1".length
  478. # "#{data_directory}#{path[start_index..-1]}"
  479. # end
  480. #
  481. # def test_parse_backup_all
  482. # @story.parse "add root".split
  483. # @story.parse "backup -all empty_dir".split
  484. #
  485. # File.open("empty_dir/Disk1/one/a.txt","r") do |file|
  486. # assert_equal "1\n", file.gets
  487. # assert_equal nil, file.gets
  488. # end
  489. #
  490. # File.open("empty_dir/Disk1/three/f.txt","r") do |file|
  491. # assert_equal "123456\n", file.gets
  492. # assert_equal nil, file.gets
  493. # end
  494. # end
  495. #
  496. # def test_parse_backup_all_only_set_directories
  497. # File.open("tmp_dir/ignore.me","a") {}
  498. # @story.parse "add root".split
  499. # @story.parse "backup -all empty_dir".split
  500. # assert_equal false, File.exist?("empty_dir/ignore.me")
  501. # end
  502. #
  503. # def test_parse_backup_message
  504. # @story.parse "add root".split
  505. # @story.parse "backup -all empty_dir".split
  506. # assert_equal Help::BACKUP_COMPLETE, @story.all_help.last.id
  507. # end
  508. #
  509. # def test_parse_add_store_root_as_property
  510. # @story.parse "add root".split
  511. # @story.parse "backup -all empty_dir".split
  512. # assert_equal Help::BACKUP_COMPLETE, @story.all_help.last.id
  513. # end
  514. end