Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pg_dump): Add '--if-exists' option for pg_dump (and add tests) #515

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

WillNilges
Copy link

Description

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:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • 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).

@DmytroLitvinov
Copy link

Hi @WillNilges ,
Thanks for the help 👍

Added your commit into my initial PR: #511

@Archmonger
Copy link
Contributor

Archmonger commented Apr 2, 2024

Just a heads up that this test seems to be broken.

@WillNilges
Copy link
Author

WillNilges commented Apr 6, 2024

Oops, that's my bad. Should work now.

@Archmonger
Copy link
Contributor

Marking this as draft due to tests failing

@Archmonger Archmonger marked this pull request as draft August 22, 2024 21:54
@Archmonger
Copy link
Contributor

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.

@Archmonger Archmonger changed the title feat(pg_dump): Add test for '--if-exists' option feat(pg_dump): Add '--if-exists' option for pg_dump (and add tests) Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dbrestore fails with non-existent relation
3 participants