Skip to content

Commit 65c623a

Browse files
authored
Merge pull request #532 from mozilla/tracy/fix_password_csv_tests
Tracy/Remove skipif's to debug in CI
2 parents 600361e + 31406f0 commit 65c623a

File tree

3 files changed

+31
-44
lines changed

3 files changed

+31
-44
lines changed

modules/page_object_about_pages.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,17 @@ def check_logins_present(
179179
else:
180180
assert expected_logins == actual_logins
181181

182-
def remove_password_csv(self, home_folder):
183-
# Delete password.csv, if there is one in test location
184-
if self.sys_platform == "Linux":
185-
downloads_folder = os.getcwd()
186-
else:
187-
downloads_folder = os.path.join(home_folder, "Downloads")
188-
passwords_csv = os.path.join(downloads_folder, "passwords.csv")
189-
for file in os.listdir(downloads_folder):
182+
def get_documents_dir(self) -> str:
183+
# Return full path to Documents directory
184+
home = os.path.expanduser("~")
185+
export_dir = os.path.join(home, "Documents")
186+
return export_dir
187+
188+
def remove_password_csv(self):
189+
# Delete password.csv, if there is one in the export location
190+
documents_dir = self.get_documents_dir()
191+
passwords_csv = os.path.join(documents_dir, "passwords.csv")
192+
for file in os.listdir(documents_dir):
190193
delete_files_regex = re.compile(r"\bpasswords.csv\b")
191194
if delete_files_regex.match(file):
192195
os.remove(passwords_csv)

tests/password_manager/test_password_csv_correctness.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,39 @@ def test_case():
2020

2121

2222
@pytest.mark.headed
23-
@pytest.mark.skipif(MAC_GHA, reason="Test unstable in MacOS Github Actions")
24-
@pytest.mark.skipif(
25-
sys.platform.lower().startswith("linux"),
26-
reason="Test unstable in CI on Linux. see bug https://bugzilla.mozilla.org/show_bug.cgi?id=1951666",
27-
)
2823
def test_password_csv_correctness(driver_and_saved_logins, home_folder, sys_platform):
2924
"""
30-
C2241522: Check that password.csv displays the correct information
25+
C2241522: Verify than an exported password.csv file displays the correct information
3126
"""
3227
# Initializing objects
3328
(driver, usernames, logins) = driver_and_saved_logins
3429
about_logins = AboutLogins(driver)
3530
keyboard = Controller()
3631

37-
# Ensure the Downloads folder doesn't contain a passwords.csv file
38-
about_logins.remove_password_csv(home_folder)
32+
# Ensure the export target folder doesn't contain a passwords.csv file
33+
about_logins.remove_password_csv()
3934

4035
# Click on buttons to export passwords
4136
about_logins.open()
4237
about_logins.click_on("menu-button")
4338
about_logins.click_on("export-passwords-button")
4439
about_logins.click_on("continue-export-button")
4540

46-
# Download the password file
41+
# Export the password file
4742
time.sleep(5)
4843
keyboard.tap(Key.enter)
4944

50-
# Verify that the file exists
51-
if sys_platform == "Linux":
52-
downloads_folder = os.getcwd()
53-
else:
54-
downloads_folder = os.path.join(home_folder, "Downloads")
55-
passwords_csv = os.path.join(downloads_folder, "passwords.csv")
56-
about_logins.wait.until(lambda _: os.path.exists(passwords_csv))
45+
# Verify the exported csv file is present in the target folder
46+
documents_directory = about_logins.get_documents_dir()
47+
csv_file = os.path.join(documents_directory, "passwords.csv")
48+
about_logins.wait.until(lambda _: os.path.exists(csv_file))
5749

58-
# Verify the results
50+
# Verify the contents of the exported csv file
5951
guid_pattern = re.compile(
6052
r"{[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}}"
6153
)
6254
time_pattern = re.compile(r"[0-9]{10}")
63-
with open(passwords_csv) as pw:
55+
with open(csv_file) as pw:
6456
reader = csv.DictReader(pw)
6557
actual_logins = {}
6658
for row in reader:
@@ -74,4 +66,4 @@ def test_password_csv_correctness(driver_and_saved_logins, home_folder, sys_plat
7466
about_logins.check_logins_present(actual_logins, logins)
7567

7668
# Delete the password.csv created
77-
about_logins.remove_password_csv(home_folder)
69+
about_logins.remove_password_csv()

tests/password_manager/test_password_csv_export.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,34 @@ def test_case():
1818

1919

2020
@pytest.mark.headed
21-
@pytest.mark.skipif(MAC_GHA, reason="Test unstable in MacOS Github Actions")
22-
@pytest.mark.skipif(
23-
sys.platform.lower().startswith("linux"),
24-
reason="Test unstable in CI on Linux. see bug https://bugzilla.mozilla.org/show_bug.cgi?id=1951666",
25-
)
2621
def test_password_csv_export(
2722
driver_and_saved_logins, home_folder, sys_platform, opt_ci
2823
):
2924
"""
30-
C2241521: Check that password.csv can be downloaded from about:logins
25+
C2241521: Verify that a password.csv file can be exported from about:logins
3126
"""
3227
# Initializing objects
3328
(driver, usernames, logins) = driver_and_saved_logins
3429
about_logins = AboutLogins(driver)
3530
keyboard = Controller()
3631

37-
# Ensure the Downloads folder doesn't contain a passwords.csv file
38-
about_logins.remove_password_csv(home_folder)
32+
# Ensure the export target folder doesn't contain a passwords.csv file
33+
about_logins.remove_password_csv()
3934

4035
# Click on buttons to export passwords
4136
about_logins.open()
4237
about_logins.click_on("menu-button")
4338
about_logins.click_on("export-passwords-button")
4439
about_logins.click_on("continue-export-button")
4540

46-
# Download the password file
41+
# Export the password file
4742
time.sleep(5)
4843
keyboard.tap(Key.enter)
4944

50-
# Verify that the file exists
51-
if sys_platform == "Linux":
52-
downloads_folder = os.getcwd()
53-
else:
54-
downloads_folder = os.path.join(home_folder, "Downloads")
55-
passwords_csv = os.path.join(downloads_folder, "passwords.csv")
56-
about_logins.wait.until(lambda _: os.path.exists(passwords_csv))
45+
# Verify the exported csv file is present in the target folder
46+
documents_directory = about_logins.get_documents_dir()
47+
csv_file = os.path.join(documents_directory, "passwords.csv")
48+
about_logins.wait.until(lambda _: os.path.exists(csv_file))
5749

5850
# Delete the password.csv created
59-
about_logins.remove_password_csv(home_folder)
51+
about_logins.remove_password_csv()

0 commit comments

Comments
 (0)