aboutsummaryrefslogtreecommitdiff
path: root/desktop/tests/test_gui_receive.py
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2022-01-17 09:51:25 -0800
committerMicah Lee <micah@micahflee.com>2022-01-17 09:51:25 -0800
commitc8ea7702232d68c81521f0755d9e55c5211807bd (patch)
tree0a3038a61a45a1716d74c75c9a07d98374deacb7 /desktop/tests/test_gui_receive.py
parent4729af55984abfaba494e31862f69f35494467e9 (diff)
parent9e99ad8b8d6f0eb0a2162191ec31a68e7c3acee5 (diff)
downloadonionshare-c8ea7702232d68c81521f0755d9e55c5211807bd.tar.gz
onionshare-c8ea7702232d68c81521f0755d9e55c5211807bd.zip
Merge branch 'ros-fixes' into release-2.5
Diffstat (limited to 'desktop/tests/test_gui_receive.py')
-rw-r--r--desktop/tests/test_gui_receive.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/desktop/tests/test_gui_receive.py b/desktop/tests/test_gui_receive.py
index 8c1c44b3..3921c6a2 100644
--- a/desktop/tests/test_gui_receive.py
+++ b/desktop/tests/test_gui_receive.py
@@ -1,3 +1,4 @@
+import glob
import pytest
import os
import requests
@@ -35,17 +36,17 @@ class TestReceive(GuiBaseTest):
now = datetime.now()
for _ in range(10):
date_dir = now.strftime("%Y-%m-%d")
- if identical_files_at_once:
- time_dir = now.strftime("%H%M%S-1")
- else:
- time_dir = now.strftime("%H%M%S")
+ time_dir = now.strftime("%H%M%S")
receive_mode_dir = os.path.join(
tab.settings.get("receive", "data_dir"), date_dir, time_dir
)
- expected_filename = os.path.join(receive_mode_dir, expected_basename)
- if os.path.exists(expected_filename):
- exists = True
- break
+ # The directories have microseconds in the name, so we need
+ # to use globbing against directory names containing the same
+ # second in order to try to find the file.
+ for path in glob.glob(receive_mode_dir + "*"):
+ if os.path.exists(os.path.join(path, expected_basename)):
+ exists = True
+ break
now = now - timedelta(seconds=1)
self.assertTrue(exists)
@@ -83,17 +84,18 @@ class TestReceive(GuiBaseTest):
for _ in range(10):
date_dir = now.strftime("%Y-%m-%d")
time_dir = now.strftime("%H%M%S")
- expected_filename = os.path.join(
+ expected_estimated_filename = os.path.join(
tab.settings.get("receive", "data_dir"),
date_dir,
- f"{time_dir}-message.txt",
+ f"{time_dir}*-message.txt",
)
- if os.path.exists(expected_filename):
- with open(expected_filename) as f:
- assert f.read() == message
+ for path in glob.glob(expected_estimated_filename):
+ if os.path.exists(path):
+ with open(path) as f:
+ assert f.read() == message
- exists = True
- break
+ exists = True
+ break
now = now - timedelta(seconds=1)
self.assertTrue(exists)