Skip to content

Commit

Permalink
test: Rebostify file download checks
Browse files Browse the repository at this point in the history
- We only want to look at fully downloaded files, but in some
  situations the tests would be fast enough to catch Firefox's *.part
  file before it gets renamed to the real name. Ignore those.

- Bring back the wait for the file be of the expected size. This seems
  to be necessary on Chromium.

- Remove the downloaded file so that the next check will not pick it
  up by accident.
  • Loading branch information
mvollmer committed Feb 8, 2025
1 parent b677445 commit 2352fa2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/check-machines-consoles
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class TestMachinesConsoles(machineslib.VirtualMachinesCase):
if content is not None:
self.assertEqual(filepath.read_text(), content)

os.unlink(filepath)

def waitViewerDownload(self, kind, host, port=5900):
self.browser.allow_download()
self.browser.click(".pf-v5-c-console__remote-viewer-launch-vv") # "Launch Remote Viewer" button
Expand All @@ -55,13 +57,17 @@ fullscreen=0
# viewer file as a randomly generated file while chromium as
# "download". As we want to download this as "$vmName.vv" in the end
# work around the issue for now.

def ready_downloads():
return list(filter(lambda p: not p.endswith(".part"), os.listdir(self.browser.driver.download_dir)))

if self.browser.browser == "chromium":
fname = "download"
else:
testlib.wait(lambda: len(os.listdir(self.browser.driver.download_dir)) == 1)
fname = os.listdir(self.browser.driver.download_dir)[0]
testlib.wait(lambda: len(ready_downloads()) == 1)
fname = ready_downloads()[0]

self.waitDownloadFile(fname, content=content)
self.waitDownloadFile(fname, content=content, expected_size=len(content))

@testlib.skipImage('SPICE not supported on RHEL', "rhel-*", "centos-*")
def testExternalConsole(self):
Expand Down

0 comments on commit 2352fa2

Please sign in to comment.