test_choose_files.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import sys
  2. import os
  3. import tempfile
  4. import shutil
  5. import unittest
  6. from lvcgui import MVCGui
  7. import datafiles
  8. import devices
  9. data = datafiles.TestData()
  10. class Test_Choose_Files(unittest.TestCase):
  11. """Add files to the conversion list either via browse or drag-n-drop.
  12. """
  13. def setUp(self):
  14. """
  15. setup app for tests
  16. """
  17. self.lvc = MVCGui()
  18. self.lvc.lvc_focus()
  19. print("starting test: ", self.shortDescription())
  20. self.output_dir = tempfile.mkdtemp()
  21. self.lvc.choose_save_location(self.output_dir)
  22. def test_browse_for_a_file(self):
  23. """Scenario: Browse for a single file.
  24. When I browse for a file
  25. Then the file is added to the list
  26. """
  27. lvc = MVCGui()
  28. datadir, testfiles = data.test_data(many=False)
  29. lvc.browse_for_files(datadir, testfiles)
  30. item = testfiles[0]
  31. assert lvc.verify_file_in_list(item)
  32. def test_choose_several_files(self):
  33. """Scenario: Browse for several files.
  34. When I browse for several files
  35. Then the files are added to the list
  36. """
  37. lvc = MVCGui()
  38. datadir, testfiles = data.test_data(many=True)
  39. lvc.browse_for_files(datadir, testfiles)
  40. for t in testfiles:
  41. assert lvc.verify_file_in_list(t)
  42. def skip_test_choose_a_directory_files(self):
  43. """Scenario: Choose a directory of files.
  44. When I browse to a directory of files
  45. Then the files are added to the list
  46. """
  47. def test_drag_a_file_to_drop_zone(self):
  48. """Scenario: Drag a single file to drop zone.
  49. When I drag a file to the drop zone
  50. Then the file is added to the list
  51. """
  52. lvc = MVCGui()
  53. datadir, testfiles = data.test_data(many=False)
  54. lvc.drag_and_drop_files(datadir, testfiles)
  55. item = testfiles[0]
  56. assert lvc.verify_file_in_list(item)
  57. def test_drag_and_drop_multiple_files(self):
  58. """Scenario: Drag multiple files.
  59. When I drag several files to the drop zone
  60. Then the files are added to the list
  61. """
  62. lvc = MVCGui()
  63. datadir, testfiles = data.test_data(many=True)
  64. lvc.drag_and_drop_files(datadir, testfiles)
  65. for t in testfiles:
  66. assert lvc.verify_file_in_list(t)
  67. def test_drag_more_files_to_drop_zone(self):
  68. """Scenario: Drag additional files to the existing list.
  69. Given I have files in the list
  70. When I drag a new file to the drop zone
  71. Then the new file is added to the list
  72. """
  73. lvc = MVCGui()
  74. datadir, testfiles = data.test_data(many=True)
  75. lvc.browse_for_files(datadir, testfiles)
  76. moredatadir, moretestfiles = data.test_data(many=False, new=True)
  77. item = testfiles[0]
  78. lvc.drag_and_drop_files(moredatadir, item)
  79. assert lvc.verify_file_in_list(item)
  80. def test_browse_for_more_files_and_add_them(self):
  81. """Scenario: Choose additional files and add to the existing list.
  82. Given I have files in the list of files
  83. When I browse for several new files
  84. Then the new files are added to the list
  85. """
  86. lvc = MVCGui()
  87. datadir, testfiles = data.test_data(many=True)
  88. lvc.browse_for_files(datadir, testfiles)
  89. moredatadir, moretestfiles = data.test_data(many=False, new=True)
  90. item = testfiles[0]
  91. lvc.browse_for_files(moredatadir, item)
  92. assert lvc.verify_file_in_list(item)
  93. def test_drag_more_file_while_converting(self):
  94. """Scenario: Drag additional files to the existing
  95. list with conversions in progress.
  96. Given I have files in the list
  97. And I start conversion
  98. When I drag a new file to the drop zone
  99. Then the new file is added to the list and is converted
  100. """
  101. lvc = MVCGui()
  102. datadir, testfiles = data.test_data(many=True)
  103. lvc.browse_for_files(datadir, testfiles)
  104. lvc.choose_device_conversion("iPad")
  105. lvc.start_conversion()
  106. moredatadir, moretestfiles = data.test_data(many=False, new=True)
  107. item = testfiles[0]
  108. lvc.drag_and_drop_files(moredatadir, item)
  109. assert lvc.verify_file_in_list(item)
  110. assert lvc.verify_completed(item, 60)
  111. def test_browse_more_files_while_converting(self):
  112. """Scenario: Choose additional files and add to
  113. list with conversions in progress.
  114. Given I have files in the list
  115. And I start conversion
  116. When I browse for several new files
  117. Then the new files are added to the list
  118. """
  119. lvc = MVCGui()
  120. datadir, testfiles = data.test_data(many=True)
  121. lvc.browse_for_files(datadir, testfiles)
  122. lvc.choose_device_conversion("iPad")
  123. lvc.start_conversion()
  124. moredatadir, moretestfiles = data.test_data(many=False, new=True)
  125. item = testfiles[0]
  126. lvc.browse_for_files(moredatadir, item)
  127. assert lvc.verify_file_in_list(item)
  128. assert lvc.verify_completed(item, 60)
  129. def tearDown(self):
  130. shutil.rmtree(self.output_dir)
  131. self.lvc_quit()