mirror of
https://github.com/Steffo99/flyingsnake.git
synced 2024-10-16 14:37:34 +00:00
Test the partial rendering
This commit is contained in:
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
BIN
tests/Small_Example_partial_prerendered.png
(Stored with Git LFS)
Normal file
Binary file not shown.
|
@ -2,10 +2,34 @@ import pytest
|
||||||
import flyingsnake
|
import flyingsnake
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
# Main integration test
|
# Main integration test
|
||||||
def test_full_render():
|
def test_full_render():
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(flyingsnake.flyingsnake, ["./tests/Small_Example.wld", "./tests/Small_Example_full.png"])
|
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()
|
||||||
|
|
Loading…
Reference in a new issue