1
Fork 0
mirror of https://github.com/Steffo99/flyingsnake.git synced 2024-10-16 06:27:34 +00:00

Test the partial rendering

This commit is contained in:
Steffo 2019-10-02 11:30:46 +02:00
parent d726e69265
commit b2421d3223
2 changed files with 28 additions and 1 deletions

BIN
tests/Small_Example_partial_prerendered.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -2,10 +2,34 @@ import pytest
import flyingsnake
from click.testing import CliRunner
from PIL import Image
import hashlib
# Main integration test
def test_full_render():
runner = CliRunner()
result = runner.invoke(flyingsnake.flyingsnake, ["./tests/Small_Example.wld", "./tests/Small_Example_full.png"])
assert Image.open("./tests/Small_Example_full.png") == Image.open("./tests/Small_Example_full_prerendered.png")
assert result.exit_code == 0
with open("Small_Example_full_prerendered.png") as prerendered:
prerendered_hash = hashlib.sha1(prerendered)
with open("Small_Example_full.png") as created:
created_hash = hashlib.sha1(created)
assert prerendered_hash.hexdigest() == created_hash.hexdigest()
def test_partial_render():
runner = CliRunner()
result = runner.invoke(flyingsnake.flyingsnake,
["./tests/Small_Example.wld", "./tests/Small_Example_partial.png",
"-x", "100",
"-y", "600",
"-w", "321",
"-h", "123"])
assert result.exit_code == 0
with open("Small_Example_partial_prerendered.png") as prerendered:
prerendered_hash = hashlib.sha1(prerendered)
with open("Small_Example_partial.png") as created:
created_hash = hashlib.sha1(created)
assert prerendered_hash.hexdigest() == created_hash.hexdigest()