Skip to content

Commit 585f8a6

Browse files
committed
Reformat files with black
1 parent db9a8a3 commit 585f8a6

File tree

4 files changed

+33
-47
lines changed

4 files changed

+33
-47
lines changed

npbackup/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def cli_interface():
112112
required=False,
113113
nargs="?",
114114
const="latest",
115-
help='Show content given snapshot. When no snapshot id is given, latest is used',
115+
help="Show content given snapshot. When no snapshot id is given, latest is used",
116116
)
117117
parser.add_argument(
118118
"--find",
@@ -219,7 +219,7 @@ def cli_interface():
219219
type=str,
220220
default=None,
221221
required=False,
222-
help="Run raw command against backend. Use with --raw \"my raw backend command\"",
222+
help='Run raw command against backend. Use with --raw "my raw backend command"',
223223
)
224224
parser.add_argument(
225225
"--init",

npbackup/core/runner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,7 @@ def convert_to_json_output(
950950
@is_ready
951951
@apply_config_to_restic_runner
952952
def init(self) -> bool:
953-
self.write_logs(
954-
f"Initializing repo {self.repo_config.g('name')}", level="info"
955-
)
953+
self.write_logs(f"Initializing repo {self.repo_config.g('name')}", level="info")
956954
return self.restic_runner.init()
957955

958956
@threaded
@@ -1633,7 +1631,8 @@ def unlock(self) -> bool:
16331631
@apply_config_to_restic_runner
16341632
def dump(self, snapshot: str, path: str) -> bool:
16351633
self.write_logs(
1636-
f"Dumping {path} from {self.repo_config.g('name')} snapshot {snapshot}", level="info"
1634+
f"Dumping {path} from {self.repo_config.g('name')} snapshot {snapshot}",
1635+
level="info",
16371636
)
16381637
result = self.restic_runner.dump(snapshot, path)
16391638
return result

npbackup/restic_wrapper/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ def dump(self, snapshot: str, path: str) -> Union[bool, str, dict]:
12601260
kwargs = locals()
12611261
kwargs.pop("self")
12621262

1263-
cmd = f'dump {snapshot} {path}'
1263+
cmd = f"dump {snapshot} {path}"
12641264
result, output = self.executor(cmd)
12651265
if result:
12661266
msg = f"File {path} successfully dumped"

tests/test_npbackup-cli.py

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
# File we will request in dump mode
6565
DUMP_FILE = "__version__.py"
6666

67+
6768
class RedirectedStdout:
6869
"""
6970
Balantly copied from https://stackoverflow.com/a/45899925/2635443
@@ -183,7 +184,7 @@ def test_npbackup_cli_init():
183184
print(str(logs))
184185
assert "created restic repository" in str(logs), "Did not create repo"
185186
assert "Repo initialized successfully" in str(logs), "Repo init failed"
186-
187+
187188

188189
def test_npbackup_cli_has_no_recent_snapshots():
189190
"""
@@ -198,11 +199,11 @@ def test_npbackup_cli_has_no_recent_snapshots():
198199
print(str(logs))
199200
json_logs = json.loads(str(logs))
200201
assert json_logs["result"] == False, "Should not have recent snapshots"
201-
202+
202203

203204
def test_npbackup_cli_create_backup():
204205
# Let's remove the repo before creating a backup since backup should auto init the repo
205-
shutil.rmtree(repo_config.g("repo_uri"), ignore_errors=True)
206+
shutil.rmtree(repo_config.g("repo_uri"), ignore_errors=True)
206207
sys.argv = ["", "-c", str(CONF_FILE), "-b"]
207208

208209
try:
@@ -299,8 +300,7 @@ def test_npbackup_cli_list_snapshots():
299300
json_logs = json.loads(str(logs))
300301
assert json_logs["result"], "Bad list result"
301302
assert json_logs["operation"] == "list", "Bogus operation name for list"
302-
assert len(json_logs["output"]["data"]) == 64, "No snapshot data found"
303-
303+
assert len(json_logs["output"]["data"]) == 64, "No snapshot data found"
304304

305305

306306
def test_npbackup_cli_find():
@@ -311,7 +311,9 @@ def test_npbackup_cli_find():
311311
print(e)
312312
except SystemExit:
313313
print(logs)
314-
assert "Found matching entries in snapshot" in str(logs), "Did not find match for find"
314+
assert "Found matching entries in snapshot" in str(
315+
logs
316+
), "Did not find match for find"
315317
assert "__version__.py", "Did not find __version__.py in find"
316318

317319

@@ -327,9 +329,7 @@ def test_npbackup_cli_check_quick():
327329
logs
328330
), "Failed quick checking repo"
329331
print(logs)
330-
assert "Repo checked successfully" in str(
331-
logs
332-
), "Quick check failed"
332+
assert "Repo checked successfully" in str(logs), "Quick check failed"
333333

334334

335335
def test_npbackup_cli_check_full():
@@ -344,9 +344,7 @@ def test_npbackup_cli_check_full():
344344
logs
345345
), "Failed full checking repo"
346346
print(logs)
347-
assert "Repo checked successfully" in str(
348-
logs
349-
), "Full check failed"
347+
assert "Repo checked successfully" in str(logs), "Full check failed"
350348

351349

352350
def test_npbackup_cli_repair_index():
@@ -357,13 +355,9 @@ def test_npbackup_cli_repair_index():
357355
print(e)
358356
except SystemExit:
359357
print(logs)
360-
assert "Repairing index in repo" in str(
361-
logs
362-
), "Index repair failed"
358+
assert "Repairing index in repo" in str(logs), "Index repair failed"
363359
print(logs)
364-
assert "Repo successfully repaired:" in str(
365-
logs
366-
), "Missing repair info"
360+
assert "Repo successfully repaired:" in str(logs), "Missing repair info"
367361

368362

369363
def test_npbackup_cli_repair_snapshots():
@@ -374,13 +368,9 @@ def test_npbackup_cli_repair_snapshots():
374368
print(e)
375369
except SystemExit:
376370
print(logs)
377-
assert "Repairing snapshots in repo" in str(
378-
logs
379-
), "Snapshot repair failed"
371+
assert "Repairing snapshots in repo" in str(logs), "Snapshot repair failed"
380372
print(logs)
381-
assert "Repo successfully repaired:" in str(
382-
logs
383-
), "Missing repair info"
373+
assert "Repo successfully repaired:" in str(logs), "Missing repair info"
384374

385375

386376
def test_npbackup_cli_retention():
@@ -434,9 +424,7 @@ def test_npbackup_cli_prune():
434424
print(e)
435425
except SystemExit:
436426
print(logs)
437-
assert "Pruning snapshots for repo" in str(
438-
logs
439-
), "Could not prune repo"
427+
assert "Pruning snapshots for repo" in str(logs), "Could not prune repo"
440428
assert "unused size after prune" in str(logs), "Did not prune"
441429
assert "Successfully pruned repository" in str(logs), "Prune failed"
442430

@@ -451,11 +439,15 @@ def test_npbackup_cli_housekeeping():
451439
print(logs)
452440
json_logs = json.loads(str(logs))
453441
assert json_logs["result"], "Bad housekeeping result"
454-
assert json_logs["operation"] == "housekeeping", "Bogus operation name for housekeeping"
442+
assert (
443+
json_logs["operation"] == "housekeeping"
444+
), "Bogus operation name for housekeeping"
455445
assert json_logs["detail"]["unlock"]["result"], "Unlock failed in housekeeping"
456446
assert json_logs["detail"]["check"]["result"], "check failed in housekeeping"
457447
assert json_logs["detail"]["forget"]["result"], "forget failed in housekeeping"
458-
assert len(json_logs["detail"]["forget"]["args"]["policy"]) > 4, "policy missing in housekeeping"
448+
assert (
449+
len(json_logs["detail"]["forget"]["args"]["policy"]) > 4
450+
), "policy missing in housekeeping"
459451
assert json_logs["detail"]["prune"]["result"], "prune failed in housekeeping"
460452

461453

@@ -469,9 +461,7 @@ def test_npbackup_cli_raw():
469461
print(e)
470462
except SystemExit:
471463
print(logs)
472-
assert "Running raw command" in str(
473-
logs
474-
), "Did not run raw command"
464+
assert "Running raw command" in str(logs), "Did not run raw command"
475465
assert "Successfully run raw command" in str(logs), "Did not run raw command"
476466
assert DUMP_FILE in str(logs), "raw ls output should contain DUMP_FILE name"
477467
for line in str(logs).split("\n"):
@@ -490,11 +480,10 @@ def test_npbackup_cli_dump():
490480
except SystemExit:
491481
print("DUMPED FILE", DUMP_FILE)
492482
print(logs)
493-
assert '__intname__ = "npbackup"' in str(
483+
assert '__intname__ = "npbackup"' in str(logs), "version file seems bogus"
484+
assert 'version_string = f"{__intname__}' in str(
494485
logs
495-
), "version file seems bogus"
496-
assert 'version_string = f"{__intname__}' in str(logs), "Version file still seems bogus"
497-
486+
), "Version file still seems bogus"
498487

499488

500489
if __name__ == "__main__":
@@ -529,13 +518,11 @@ def test_npbackup_cli_dump():
529518
test_npbackup_cli_check_full()
530519
test_npbackup_cli_repair_index()
531520
test_npbackup_cli_repair_snapshots()
532-
521+
533522
# Repairing packs needs pack ids
534-
#test_npbackup_cli_repair_packs()
523+
# test_npbackup_cli_repair_packs()
535524

536525
test_npbackup_cli_housekeeping()
537526

538527
test_npbackup_cli_raw()
539528
test_npbackup_cli_dump()
540-
541-

0 commit comments

Comments
 (0)