Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_truncate_middle(self):
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)
def test_truncate_middle(self):
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)
def test_truncate_middle(self):
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)
def test_truncate_middle(self):
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)
def test_truncate_middle(self):
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)
def test_truncate_middle(self):
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)
def test_truncate_middle(self):
assert truncate_middle("test_filename.jpg", 50) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 17) == "test_filename.jpg"
assert truncate_middle("test_filename.jpg", 16) == "test_f...me.jpg"
assert truncate_middle("test_filename.jpg", 10) == "tes...jpg"
assert truncate_middle("test_filename.jpg", 5) == "t...g"
assert truncate_middle("test_filename.jpg", 4) == "...g"
assert truncate_middle("test_filename.jpg", 3) == "..."
assert truncate_middle("test_filename.jpg", 2) == ".."
assert truncate_middle("test_filename.jpg", 1) == "."
assert truncate_middle("test_filename.jpg", 0) == ""
with self.assertRaises(ValueError):
truncate_middle("test_filename.jpg", -1)
if os.path.exists("tests/fixtures/Photos"):
shutil.rmtree("tests/fixtures/Photos")
os.makedirs("tests/fixtures/Photos")
with mock.patch("icloudpd.download.download_media") as dp_patched:
dp_patched.return_value = True
with mock.patch.object(PhotoAsset, "versions") as pa:
pa.return_value = ["original", "medium"]
with vcr.use_cassette("tests/vcr_cassettes/listing_photos.yml"):
# Pass fixed client ID via environment variable
os.environ["CLIENT_ID"] = "DE309E26-942E-11E8-92F5-14109FE0B321"
runner = CliRunner()
result = runner.invoke(
main,
[
"--username",
"jdoe@gmail.com",
"--password",
"password1",
"--recent",
"1",
"--size",
"thumb",
"--force-size",
"--no-progress-bar",
"-d",
base_dir,
],
)
print_result_exception(result)
def test_2sa_flow_sms(self):
with vcr.use_cassette("tests/vcr_cassettes/2sa_flow_valid_sms.yml"):
os.environ["CLIENT_ID"] = "DE309E26-942E-11E8-92F5-14109FE0B321"
runner = CliRunner()
result = runner.invoke(
main,
[
"--username",
"jdoe@gmail.com",
"--password",
"password1",
"--recent",
"0",
"--no-progress-bar",
"-d",
"tests/fixtures/Photos",
],
input="0\n123456\n",
)
self.assertIn("DEBUG Authenticating...", self._caplog.text)
self.assertIn(
"INFO Two-step/two-factor authentication is required!",
def test_password_prompt(self):
if not os.path.exists("tests/fixtures/Photos"):
os.makedirs("tests/fixtures/Photos")
with vcr.use_cassette("tests/vcr_cassettes/listing_photos.yml"):
os.environ["CLIENT_ID"] = "DE309E26-942E-11E8-92F5-14109FE0B321"
runner = CliRunner()
result = runner.invoke(
main,
[
"--username",
"jdoe@gmail.com",
"--recent",
"0",
"--no-progress-bar",
"-d",
"tests/fixtures/Photos",
],
input="password1\n",
)
self.assertIn("DEBUG Authenticating...", self._caplog.text)
self.assertIn(
"DEBUG Looking up all photos and videos from album All Photos...", self._caplog.text
)
self.assertIn(