move test images to local storage and remove get requests
Run Tests / Run Tests (push) Successful in 37s
Details
Run Tests / Run Tests (push) Successful in 37s
Details
This commit is contained in:
parent
12bf8ec601
commit
bb8c29ea91
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 751 KiB |
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
|
@ -29,19 +29,21 @@ def cleanup_uploaded_files():
|
|||
|
||||
image_memo.delete()
|
||||
|
||||
|
||||
def get_test_filepath(basename):
|
||||
return os.path.join(os.path.dirname(__file__), "data", basename)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_document_thumbnail_incorrect_user(client, cleanup_uploaded_files):
|
||||
user1 = User.objects.create_user(email="user1@test.com", password="password1")
|
||||
user2 = User.objects.create_user(email="user2@test.com", password="password2")
|
||||
|
||||
print(user2)
|
||||
|
||||
r = requests.get(
|
||||
"https://www.w3.org/MarkUp/Test/xhtml-print/20050519/tests/jpeg420exif.jpg"
|
||||
)
|
||||
with open(get_test_filepath("example.jpg"), "rb") as f:
|
||||
img_content = f.read()
|
||||
|
||||
test_image = SimpleUploadedFile(
|
||||
name="test_image.jpg", content=r.content, content_type="image/jpeg"
|
||||
name="test_image.jpg", content=img_content, content_type="image/jpeg"
|
||||
)
|
||||
|
||||
image_memo = ImageMemo.objects.create(
|
||||
|
@ -70,14 +72,16 @@ def test_document_thumbnail_incorrect_user(client, cleanup_uploaded_files):
|
|||
assert response.status_code == 200
|
||||
assert response["Content-Type"] == "image/jpeg"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_document_thumbnail_golden_path_png(client, cleanup_uploaded_files):
|
||||
user = User.objects.create_user(email="user@test.com", password="password")
|
||||
|
||||
r = requests.get("https://brainsteam.co.uk/images/avatar_small.png")
|
||||
with open(get_test_filepath("example.png"), "rb") as f:
|
||||
img_content = f.read()
|
||||
|
||||
test_image = SimpleUploadedFile(
|
||||
name="test_image.png", content=r.content, content_type="image/png"
|
||||
name="test_image.png", content=img_content, content_type="image/png"
|
||||
)
|
||||
|
||||
image_memo = ImageMemo.objects.create(
|
||||
|
@ -97,16 +101,16 @@ def test_document_thumbnail_golden_path_png(client, cleanup_uploaded_files):
|
|||
assert response.status_code == 200
|
||||
assert response["Content-Type"] == "image/jpeg"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_document_thumbnail_golden_path_gif(client, cleanup_uploaded_files):
|
||||
user = User.objects.create_user(email="user@test.com", password="password")
|
||||
|
||||
r = requests.get(
|
||||
"https://upload.wikimedia.org/wikipedia/commons/a/a0/Sunflower_as_gif_websafe.gif"
|
||||
)
|
||||
with open(get_test_filepath("example.gif"), "rb") as f:
|
||||
img_content = f.read()
|
||||
|
||||
test_image = SimpleUploadedFile(
|
||||
name="test_image.gif", content=r.content, content_type="image/gif"
|
||||
name="test_image.gif", content=img_content, content_type="image/gif"
|
||||
)
|
||||
|
||||
image_memo = ImageMemo.objects.create(
|
||||
|
|
Loading…
Reference in New Issue