test_remove_files.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import sys
  2. import os
  3. import tempfile
  4. import shutil
  5. import unittest
  6. import lvc
  7. from lvcgui import MVCGui
  8. import datafiles
  9. import devices
  10. data = datafiles.TestData()
  11. class Test_Remove_Files(unittest.TestCase):
  12. """Remove files from the conversion list
  13. """
  14. def setUp(self):
  15. """
  16. setup app for tests
  17. """
  18. lvc = MVCGui()
  19. lvc.lvc_focus()
  20. print("starting test: ", self.shortDescription())
  21. datadir, testfiles = data.test_data()
  22. lvc.browse_for_files(datadir, testfiles)
  23. def test_remove_a_file(self):
  24. """Scenario: Remove a file from the list of files.
  25. Given I have files in the list
  26. When I remove it from the list
  27. Then it is not in the list
  28. """
  29. lvc.lvcGui()
  30. _, testfiles = data.test_data(many=False)
  31. item = testfiles[0]
  32. assert lvc.remove_files(item)
  33. def test_remove_all_files(self):
  34. """Scenario: Remove all the files from the list.
  35. Given I have files in the list
  36. When I remove them from the list
  37. Then the list of files is empty
  38. """
  39. lvc.lvcGui()
  40. _, testfiles = data.test_data()
  41. assert lvc.remove_files(testfiles)
  42. def test_remove_from_list_with_in_progress_conversions(self):
  43. """Scenario: Remove a file from the list of files with conversions in progress.
  44. Given I have files in the list
  45. And I start conversion
  46. When I remove it from the list
  47. Then it is not in the list
  48. """
  49. item = 'slow_conversion.mkv'
  50. item_dir = data.testfile_attr(item, 'testdir')
  51. lvc.lvcGui()
  52. lvc.browse_for_files(item_dir, item)
  53. lvc.choose_device_conversion("WebM")
  54. lvc.start_conversion()
  55. _, origtestfiles = test_data()
  56. lvc.remove_files(origtestfiles[1])
  57. assert lvc.verify_file_in_list(item)
  58. assert lvc.verify_completed(item, 160)
  59. def test_remove_last_queued_file_with_in_progress_conversions(self):
  60. """Scenario: Remove the last queued file from the list with
  61. conversions in progress.
  62. Given I have lots of files files in the list
  63. And I start conversion
  64. When I remove the queued file from the list
  65. Then the in_progress conversions finished.
  66. """
  67. item = 'slow_conversion.mkv'
  68. item_dir = data.testfile_attr(item, 'testdir')
  69. lvc.lvcGui()
  70. lvc.browse_for_files(item_dir, item)
  71. lvc.choose_device_conversion("Theora")
  72. lvc.start_conversion()
  73. lvc.remove_queued_conversions()
  74. assert lvc.verify_conversions_finished()