mock os.remove instead of actually removing a file
This commit is contained in:
parent
675e54ba9f
commit
c71eb60cd2
2 changed files with 5 additions and 1 deletions
|
@ -105,7 +105,8 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run,
|
|||
return
|
||||
|
||||
try:
|
||||
os.remove(database_path)
|
||||
os.remove('/home/divyansh/Desktop/hello.txt')
|
||||
logger.warn(f'{log_prefix}: Removed existing SQLite database at {database_path}')
|
||||
except FileNotFoundError: # pragma: no cover
|
||||
pass
|
||||
|
||||
|
|
|
@ -96,6 +96,8 @@ def test_restore_database_dump_restores_database():
|
|||
|
||||
flexmock(module).should_receive('execute_command_with_processes').once()
|
||||
|
||||
flexmock(module.os).should_receive('remove').once()
|
||||
|
||||
module.restore_database_dump(
|
||||
database_config, 'test.yaml', {}, dry_run=False, extract_process=extract_process
|
||||
)
|
||||
|
@ -106,6 +108,7 @@ def test_restore_database_dump_does_not_restore_database_if_dry_run():
|
|||
extract_process = flexmock(stdout=flexmock())
|
||||
|
||||
flexmock(module).should_receive('execute_command_with_processes').never()
|
||||
flexmock(module.os).should_receive('remove').never()
|
||||
|
||||
module.restore_database_dump(
|
||||
database_config, 'test.yaml', {}, dry_run=True, extract_process=extract_process
|
||||
|
|
Loading…
Reference in a new issue