lvc_steps.py 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. # -*- coding: utf-8 -*-
  2. from lettuce import step
  3. from lettuce import world
  4. import datafiles
  5. import devices
  6. data = datafiles.TestData()
  7. DEFAULT_DEVICE = "iPad"
  8. def test_data(many=False, new=False):
  9. UNITTESTFILES = ['mp4-0.mp4', 'webm-0.webm', 'drm.m4v']
  10. SIKTESTFILES = ['baby_block.m4v', 'story_styff.mov']
  11. if new:
  12. TESTFILES = SIKTESTFILES
  13. else:
  14. TESTFILES = UNITTESTFILES
  15. DATADIR = data.testfile_attr(TESTFILES[0], 'testdir')
  16. if not many:
  17. TESTFILES = TESTFILES[:1]
  18. print(TESTFILES)
  19. return DATADIR, TESTFILES
  20. def device_group(option):
  21. menu_group = devices.dev_attr(option, 'group')
  22. return menu_group
  23. def device_output(option):
  24. dev_output_format = devices.dev_attr(option, 'container')
  25. return device_output_format
  26. @step('I browse for (?:a|several)( new)? file(s)?')
  27. # file or files determines 1 or many
  28. def browse_for_files(step, new, several):
  29. datadir, testfiles = test_data(several, new)
  30. print(testfiles)
  31. world.lvc.browse_for_files(datadir, testfiles)
  32. @step('The( new)? file(s)? (?:is|are) added to the list')
  33. def files_added_to_the_list(step, new, several):
  34. _, testfiles = test_data(several, new)
  35. for t in testfiles:
  36. assert world.lvc.verify_file_in_list(t)
  37. @step('I browse to a directory of files')
  38. def add_a_directory(step):
  39. datadir, _ = test_data(many=True)
  40. world.lvc.add_directory_of_files(datadir)
  41. @step(u'When I drag (?:a|several)( new)? file(s)? to the drop zone')
  42. def drag_to_the_drop_zone(step, new, several):
  43. datadir, testfiles = test_data(several, new)
  44. world.lvc.drag_and_drop_files(datadir, testfiles)
  45. @step('Given I have files in the list')
  46. def given_i_have_some_files(step):
  47. step.given('I browse for several files')
  48. @step('I start conversion')
  49. def start_conversion(step):
  50. world.lvc.start_conversions()
  51. @step('I remove "([^"]*)" from the list')
  52. def when_i_remove_it_from_the_list(step, items):
  53. if items == "it":
  54. _, testfile = test_data()
  55. elif items == "them":
  56. _, testfile = test_data(True, False)
  57. else:
  58. testfile = items.split(', ')
  59. world.lvc.remove_files(testfile)
  60. @step('"([^"]*)" is not in the list')
  61. def not_in_the_list(step, items):
  62. if items == "it":
  63. _, testfile = test_data()
  64. assert False, world.lvc.verify_file_in_list(testfile)
  65. @step('I remove each of them from the list')
  66. def i_remove_each_of_them_from_the_list(step):
  67. assert False, 'This step must be implemented'
  68. @step(u'Then the list of files is empty')
  69. def then_the_list_of_files_is_empty(step):
  70. assert False, 'This step must be implemented'
  71. @step('I have converted (?:a|some) file(s)?')
  72. def have_converted_file(step, amount):
  73. if amount is None:
  74. # file or files determines 1 or many
  75. browse_file = ('I browse for a file')
  76. else:
  77. browse_file = ('I browse for some files')
  78. step.given(browse_file)
  79. step.given('I choose the "test_default" device option')
  80. step.given('I start conversion')
  81. @step('I clear finished conversions')
  82. def clear_finished_conversions(step, testfiles):
  83. world.lvc.clear_finished_files()
  84. @step('I (?:convert|have converted) "(.*?)" to "(.*?)"')
  85. def convert_file_to_format(step, filename, device):
  86. datadir = data.testfile_attr(filename, 'testdir')
  87. world.lvc.browse_for_files(datadir, [filename])
  88. world.lvc.choose_device_conversion(device)
  89. world.lvc.start_conversions()
  90. @step('the "(.*?)" (?:is|are) removed')
  91. def file_is_removed(step, testfile):
  92. if testfile == "file":
  93. _, testfile = test_data()
  94. assert world.lvc.verify_file_not_in_list(testfile)
  95. @step('And I have some conversions in progress')
  96. def and_i_have_some_conversions_in_progress(step):
  97. assert False, 'This step must be implemented'
  98. @step('the completed files are removed')
  99. def completed_files_are_removed(step):
  100. assert world.lvc.verify_completed_removed()
  101. @step('the in-progress conversions remain')
  102. def and_the_in_progress_conversions_remain(step):
  103. assert world.lvc.verify_in_progress()
  104. @step('"(.*?)" is a failed conversion')
  105. def have_failed_conversion(step, item):
  106. assert verify_failed(self, item)
  107. @step('the failed conversions are removed')
  108. def failed_conversions_removed(step):
  109. assert world.lvc.verify_failed_removed()
  110. @step('I choose the custom size option')
  111. def change_custom_size(step):
  112. world.lvc.choose_custom_size('on', '150', '175')
  113. assert world.lvc.verify_test_img('_custom_size_test')
  114. @step('I choose the aspect ratio')
  115. def when_i_choose_the_aspect_ratio(step):
  116. assert False, 'This step must be implemented'
  117. @step('I choose the "([^"]*)" (?:device|format) option')
  118. def choose_conversion_format(step, device):
  119. if device == 'test_default':
  120. device = DEFAULT_DEVICE
  121. world.lvc.choose_device_conversion(device)
  122. @step('I open the custom pulldown')
  123. def open_custom_pulldown(step):
  124. world.lvc.open_custom_menu()
  125. @step('I verify "([^"]*)" and "([^"]*)" size setting entry')
  126. def verify_the_size_value(step, width, height):
  127. assert False, 'This step must be implemented'
  128. @step('I verify the "([^"]*)" (?:device|format)( not)? selected')
  129. def verify_format_selection_for_device(self, device, removed):
  130. if removed:
  131. assert False, world.lvc.verify_device_format_selected(device)
  132. else:
  133. assert world.lvc.verify_device_format_selected(device)
  134. @step('the menu is reset')
  135. def menu_is_reset(step):
  136. assert False, 'This step must be implemented'
  137. @step(u'Then there should be some smart way to make sure that the size and aspect ratio values are not conflicting')
  138. def then_there_should_be_some_smart_way_to_make_sure_that_the_size_and_aspect_ratio_values_are_not_conflicting(step):
  139. assert False, 'This step must be implemented'
  140. @step(u'And therefore if you have a size selected, and then select an aspect ratio, a valid size should be calculated based on the chosen width and the size value should be updated.')
  141. def and_therefore_if_you_have_a_size_selected_and_then_select_an_aspect_ratio_a_valid_size_should_be_calculated_based_on_the_chosen_width_and_the_size_value_should_be_updated(step):
  142. assert False, 'This step must be implemented'
  143. @step(u'When I restart lvc')
  144. def when_i_restart_lvc(step):
  145. assert False, 'This step must be implemented'
  146. @step('I have Send to iTunes checked')
  147. def and_i_have_send_to_itunes_checked(step):
  148. assert False, 'This step must be implemented'
  149. @step('the file is added to my iTunes library')
  150. def file_added_to_itunes(step):
  151. assert False, 'This step must be implemented'
  152. @step(u'And I have the (default)? output directory specified')
  153. def and_i_have_the_output_directory_specified(step, default):
  154. assert False, 'This step must be implemented'
  155. @step('the output file is in the (specified|default) directory')
  156. def output_file_specified_directory(step):
  157. assert False, 'This step must be implemented'
  158. @step(u'Then is named with the file name (or even better item title) as the base')
  159. def then_is_named_with_the_file_name_or_even_better_item_title_as_the_base(step):
  160. assert False, 'This step must be implemented'
  161. @step(u'And the output container is the extension')
  162. def and_the_output_container_is_the_extension(step):
  163. assert False, 'This step must be implemented'
  164. @step(u'Then the output file is resized correctly')
  165. def then_the_output_file_is_resized_correctly(step):
  166. assert False, 'This step must be implemented'
  167. @step(u'When I view the ffmpeg output')
  168. def when_i_view_the_ffmpeg_output(step):
  169. assert False, 'This step must be implemented'
  170. @step('the ffmpeg output is displayed in a text window')
  171. def then_the_ffmpeg_output_is_displayed_in_a_text_window(step):
  172. assert False, 'This step must be implemented'