This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/attachments/tests/test_models.py

20 lines
671 B
Python

from pathlib import Path
import pytest
from django.core.files import File
from attachments.models import Attachment
@pytest.mark.block_network
@pytest.mark.vcr
@pytest.mark.django_db
def test_attachment_is_processed_by_shortpixel():
# This path manipulation is required to make the test run from this directory
# or from upper in the hierarchy (e.g.: settings.BASE_DIR)
img_path = Path(__file__).parent / "resources" / "image.png"
img_path = img_path.relative_to(Path.cwd())
with open(img_path, "rb") as f:
img_file = File(f)
attachment = Attachment(description="test attachment", original_file=img_file)
attachment.save()