1
Fork 0
mirror of https://github.com/Steffo99/flyingsnake.git synced 2024-12-22 14:44:17 +00:00
flyingsnake/tests/test_flyingsnake.py

36 lines
1.3 KiB
Python
Raw Normal View History

2019-09-28 20:32:02 +00:00
import pytest
import flyingsnake
from click.testing import CliRunner
from PIL import Image
2019-10-02 09:30:46 +00:00
import hashlib
2019-09-28 20:32:02 +00:00
# Main integration test
def test_full_render():
runner = CliRunner()
2019-09-28 22:58:42 +00:00
result = runner.invoke(flyingsnake.flyingsnake, ["./tests/Small_Example.wld", "./tests/Small_Example_full.png"])
2019-10-02 09:30:46 +00:00
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()