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

Fix Issue #708: Save files with string content #911

Merged

Commits on Sep 4, 2023

  1. Add alternate .venv to gitignore

    LincolnPuzey authored and jschneier committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    587a42a View commit details
    Browse the repository at this point in the history
  2. Add moto as test dependency.

    LincolnPuzey authored and jschneier committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    667a354 View commit details
    Browse the repository at this point in the history
  3. Add ReadBytesWrapper utility class for wrapping a file-like object.

    This makes .read() always return bytes.
    If .read() returns a string, it will be encoded to bytes before being returned.
    The encoding to use can be specified, otherwise will use the .encoding property of the original file, otherwise will use utf-8.
    LincolnPuzey authored and jschneier committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    c36c683 View commit details
    Browse the repository at this point in the history
  4. Fix issue jschneier#708: Make _save() wrap content in a ReadBytesWrap…

    …per.
    
    This correctly handles file-like-objects that are open in text/string mode by converting to strings returned by read() to bytes, which is what upload_fileobj() requires.
    This is done before gzip compressing, so also removed force_bytes() call in _compress_content().
    LincolnPuzey authored and jschneier committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    5f742cd View commit details
    Browse the repository at this point in the history
  5. Add tests for saving both File/ContentFile with string/bytes.

    Add these tests in a new test class that uses moto. Remove old test for saving ContentFile
    Move test for detecting content-type to this new class. Add some more tests around this.
    Fix tests that fail because settings.AWS_STORAGE_BUCKET_NAME is now defined.
    Fix tests that fail because content is always wrapped.
    Fix test for gzipped file since that now only takes bytes.
    LincolnPuzey authored and jschneier committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    79c25ad View commit details
    Browse the repository at this point in the history
  6. tweaks

    jschneier committed Sep 4, 2023
    Configuration menu
    Copy the full SHA
    1f45042 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    7e9f18a View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    577bb21 View commit details
    Browse the repository at this point in the history