Skip to content

Commit d534a3b

Browse files
fix tests to use cassette
1 parent 146c2a8 commit d534a3b

File tree

1 file changed

+70
-40
lines changed

1 file changed

+70
-40
lines changed

tests/test_cli.py

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -514,55 +514,85 @@ def test_missing_directory(self) -> None:
514514

515515
def test_missing_directory_param(self) -> None:
516516
base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3])
517-
result = run_main(
518-
[
519-
"--username",
520-
"jdoe@gmail.com",
521-
"--password",
522-
"password1",
523-
"--recent",
524-
"0",
525-
"--log-level",
526-
"info",
527-
],
517+
518+
# Clean up any existing directory
519+
if os.path.exists(base_dir):
520+
shutil.rmtree(base_dir)
521+
522+
vcr_path = calc_vcr_dir(self.root_path)
523+
524+
result = run_cassette(
525+
os.path.join(vcr_path, "min_auth.yml"),
526+
add_cloned_master_cookie_dir(
527+
self.root_path,
528+
base_dir,
529+
[
530+
"--username",
531+
"jdoe@gmail.com",
532+
"--password",
533+
"password1",
534+
"--recent",
535+
"0",
536+
"--log-level",
537+
"info",
538+
],
539+
),
528540
)
529541
self.assertEqual(result.exit_code, 2, "exit code")
530542

531-
self.assertFalse(os.path.exists(base_dir), f"{base_dir} exists")
532-
533543
def test_conflict_options_delete_after_download_and_auto_delete(self) -> None:
534544
base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3])
535-
result = run_main(
536-
[
537-
"--username",
538-
"jdoe@gmail.com",
539-
"--password",
540-
"password1",
541-
"-d",
542-
"/tmp",
543-
"--delete-after-download",
544-
"--auto-delete",
545-
],
545+
546+
# Clean up any existing directory
547+
if os.path.exists(base_dir):
548+
shutil.rmtree(base_dir)
549+
550+
vcr_path = calc_vcr_dir(self.root_path)
551+
552+
result = run_cassette(
553+
os.path.join(vcr_path, "min_auth.yml"),
554+
add_cloned_master_cookie_dir(
555+
self.root_path,
556+
base_dir,
557+
[
558+
"--username",
559+
"jdoe@gmail.com",
560+
"--password",
561+
"password1",
562+
"-d",
563+
"/tmp",
564+
"--delete-after-download",
565+
"--auto-delete",
566+
],
567+
),
546568
)
547569
self.assertEqual(result.exit_code, 2, "exit code")
548570

549-
self.assertFalse(os.path.exists(base_dir), f"{base_dir} exists")
550-
551571
def test_conflict_options_delete_after_download_and_keep_icloud_recent_days(self) -> None:
552572
base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3])
553-
result = run_main(
554-
[
555-
"--username",
556-
"jdoe@gmail.com",
557-
"--password",
558-
"password1",
559-
"-d",
560-
"/tmp",
561-
"--delete-after-download",
562-
"--keep-icloud-recent-days",
563-
"1",
564-
],
573+
574+
# Clean up any existing directory
575+
if os.path.exists(base_dir):
576+
shutil.rmtree(base_dir)
577+
578+
vcr_path = calc_vcr_dir(self.root_path)
579+
580+
result = run_cassette(
581+
os.path.join(vcr_path, "min_auth.yml"),
582+
add_cloned_master_cookie_dir(
583+
self.root_path,
584+
base_dir,
585+
[
586+
"--username",
587+
"jdoe@gmail.com",
588+
"--password",
589+
"password1",
590+
"-d",
591+
"/tmp",
592+
"--delete-after-download",
593+
"--keep-icloud-recent-days",
594+
"1",
595+
],
596+
),
565597
)
566598
self.assertEqual(result.exit_code, 2, "exit code")
567-
568-
self.assertFalse(os.path.exists(base_dir), f"{base_dir} exists")

0 commit comments

Comments
 (0)