Skip to content

Commit 2352fa2

Browse files
committed
test: Rebostify file download checks
- 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.
1 parent b677445 commit 2352fa2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/check-machines-consoles

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class TestMachinesConsoles(machineslib.VirtualMachinesCase):
3939
if content is not None:
4040
self.assertEqual(filepath.read_text(), content)
4141

42+
os.unlink(filepath)
43+
4244
def waitViewerDownload(self, kind, host, port=5900):
4345
self.browser.allow_download()
4446
self.browser.click(".pf-v5-c-console__remote-viewer-launch-vv") # "Launch Remote Viewer" button
@@ -55,13 +57,17 @@ fullscreen=0
5557
# viewer file as a randomly generated file while chromium as
5658
# "download". As we want to download this as "$vmName.vv" in the end
5759
# work around the issue for now.
60+
61+
def ready_downloads():
62+
return list(filter(lambda p: not p.endswith(".part"), os.listdir(self.browser.driver.download_dir)))
63+
5864
if self.browser.browser == "chromium":
5965
fname = "download"
6066
else:
61-
testlib.wait(lambda: len(os.listdir(self.browser.driver.download_dir)) == 1)
62-
fname = os.listdir(self.browser.driver.download_dir)[0]
67+
testlib.wait(lambda: len(ready_downloads()) == 1)
68+
fname = ready_downloads()[0]
6369

64-
self.waitDownloadFile(fname, content=content)
70+
self.waitDownloadFile(fname, content=content, expected_size=len(content))
6571

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

0 commit comments

Comments
 (0)