import os from PIL import Image as PILImage from spectra.display import InkyDisplay class TestInkyDisplayOrientation: def test_effective_dimensions_landscape(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=0) assert d.effective_width == 800 assert d.effective_height == 480 def test_effective_dimensions_portrait(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=90) assert d.effective_width == 480 assert d.effective_height == 800 def test_output_size_0(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=0) r = d.process_image(PILImage.new("RGB", (1600, 1200))) assert r.size == (800, 480) def test_output_size_90(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=90) r = d.process_image(PILImage.new("RGB", (1600, 1200))) assert r.size == (800, 480) def test_output_size_180(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=180) r = d.process_image(PILImage.new("RGB", (1600, 1200))) assert r.size == (800, 480) def test_output_size_270(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=270) r = d.process_image(PILImage.new("RGB", (1600, 1200))) assert r.size == (800, 480) def test_string_orientation_coerced(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation="90") assert d.orientation == 90 def test_none_orientation_defaults_to_zero(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=None) assert d.orientation == 0 def test_show_writes_file(self): d = InkyDisplay(simulate=True, width=800, height=480, orientation=90) d.show(PILImage.new("RGB", (1600, 1200))) assert os.path.exists("/tmp/spectra_last.png")