django-dbbackup
django-dbbackup copied to clipboard
feat(pg_dump): Add '--if-exists' option for pg_dump (and add tests)
Description
- Adds
--if-existsoption forpg_dumpcommand - Resolves #478
- Adds simple test
Extension of #511. If I understand correctly this was precluded on missing a test? I have added it, and was hoping to get this merged so I can use it in production 🙇🏻
Feel free to cherry pick my commit onto @DmytroLitvinov's PR or however you want to do it, I just wanted the feature to move 😅
Checklist
Please update this checklist as you complete each item:
- [X] Tests have been developed for bug fixes or new functionality.
- [ ] The changelog has been updated, if necessary.
- [ ] Documentation has been updated, if necessary.
- [X] GitHub Issues closed by this PR have been linked.
By submitting this pull request I agree that all contributions comply with this project's open source license(s).
Hi @WillNilges , Thanks for the help 👍
Added your commit into my initial PR: https://github.com/jazzband/django-dbbackup/pull/511
Just a heads up that this test seems to be broken.
Oops, that's my bad. Should work now.
Marking this as draft due to tests failing
The following error will need to be resolved
Traceback (most recent call last):
File "/home/runner/work/django-dbbackup/django-dbbackup/.tox/py38-django42/lib/python3.8/site-packages/gnupg.py", line 159, in _copy_data
outstream.write(data)
TypeError: a bytes-like object is required, not 'str'
....ERROR Exception: Foo
File "/home/runner/work/django-dbbackup/django-dbbackup/dbbackup/utils.py", line 119, in wrapper
func(*args, **kwargs)
File "/home/runner/work/django-dbbackup/django-dbbackup/dbbackup/tests/test_utils.py", line 81, in func
raise Exception("Foo")
.ERROR Exception: Foo
File "/home/runner/work/django-dbbackup/django-dbbackup/dbbackup/utils.py", line 119, in wrapper
func(*args, **kwargs)
File "/home/runner/work/django-dbbackup/django-dbbackup/dbbackup/tests/test_utils.py", line 91, in func
raise Exception("Foo")
..ERROR Error sending data
Traceback (most recent call last):
File "/home/runner/work/django-dbbackup/django-dbbackup/.tox/py38-django42/lib/python3.8/site-packages/gnupg.py", line 159, in _copy_data
outstream.write(data)
TypeError: a bytes-like object is required, not 'str'
Somehow your changes broke test_raise_error_without_mail
@patch("dbbackup.settings.SEND_EMAIL", False)
def test_raise_error_without_mail(self):
def func():
raise Exception("Foo")
with self.assertRaises(Exception):
utils.email_uncaught_exception(func)()
self.assertEqual(len(mail.outbox), 0)
Specifically, it seems like gnupg is trying to encrypt some values before sending the email but it is receiving a string instead of bytes.
Truthfully, I am not sure how your changes could have caused this.