diff --git a/src/main/python/main/ayab/tests/test_control.py b/src/main/python/main/ayab/tests/test_control.py index e4c2f5ad..5d47a2b7 100644 --- a/src/main/python/main/ayab/tests/test_control.py +++ b/src/main/python/main/ayab/tests/test_control.py @@ -54,7 +54,9 @@ def setUp(self): def test__singlebed(self): control = Control(self.parent, self.parent.engine) - control.pattern = Pattern(Image.new("P", (1, 3)), Config(Machine(0)), 2) + control.pattern = Pattern( + Image.new("P", (1, 3)), Config(Machine.KH910_KH950), 2 + ) control.num_colors = 2 control.start_row = 0 control.inf_repeat = False @@ -72,7 +74,7 @@ def test__singlebed(self): def test__classic_ribber_2col(self): control = Control(self.parent, self.parent.engine) control.pattern = Pattern( - Image.new("P", (1, 5)), Config(Machine(0), Mode.CLASSIC_RIBBER), 2 + Image.new("P", (1, 5)), Config(Machine.KH910_KH950, Mode.CLASSIC_RIBBER), 2 ) control.num_colors = 2 control.start_row = 0 @@ -101,7 +103,7 @@ def test__classic_ribber_2col(self): def test__classic_ribber_multicol(self): control = Control(self.parent, self.parent.engine) control.pattern = Pattern( - Image.new("P", (1, 3)), Config(Machine(0), Mode.CLASSIC_RIBBER), 3 + Image.new("P", (1, 3)), Config(Machine.KH910_KH950, Mode.CLASSIC_RIBBER), 3 ) control.num_colors = 3 control.start_row = 0 @@ -135,7 +137,9 @@ def test__classic_ribber_multicol(self): def test__middlecolorstwice_ribber(self): control = Control(self.parent, self.parent.engine) control.pattern = Pattern( - Image.new("P", (1, 5)), Config(Machine(0), Mode.MIDDLECOLORSTWICE_RIBBER), 3 + Image.new("P", (1, 5)), + Config(Machine.KH910_KH950, Mode.MIDDLECOLORSTWICE_RIBBER), + 3, ) control.mode = Mode.MIDDLECOLORSTWICE_RIBBER control.num_colors = 3 @@ -177,7 +181,9 @@ def test__middlecolorstwice_ribber(self): def test__heartofpluto_ribber(self): control = Control(self.parent, self.parent.engine) control.pattern = Pattern( - Image.new("P", (1, 5)), Config(Machine(0), Mode.HEARTOFPLUTO_RIBBER), 3 + Image.new("P", (1, 5)), + Config(Machine.KH910_KH950, Mode.HEARTOFPLUTO_RIBBER), + 3, ) control.mode = Mode.HEARTOFPLUTO_RIBBER control.num_colors = 3 @@ -219,7 +225,7 @@ def test__heartofpluto_ribber(self): def test__circular_ribber(self): control = Control(self.parent, self.parent.engine) control.pattern = Pattern( - Image.new("P", (1, 3)), Config(Machine(0), Mode.CIRCULAR_RIBBER), 3 + Image.new("P", (1, 3)), Config(Machine.KH910_KH950, Mode.CIRCULAR_RIBBER), 3 ) control.num_colors = 3 control.start_row = 0 @@ -252,29 +258,28 @@ def test__circular_ribber(self): def test_select_needles_API6(self): control = Control(self.parent, self.parent.engine) - control.machine = Machine(0) + control.machine = Machine.KH910_KH950 control.num_colors = 2 control.start_row = 0 # 40 pixel image set to the left control.mode = Mode.SINGLEBED im = Image.new("P", (40, 3), 0) - im1 = Image.new("P", (40, 1), 1) - im.paste(im1, (0, 0)) - pattern = Pattern(im, Config(Machine(0), Mode.SINGLEBED), 2) - pattern.alignment = Alignment.LEFT + im1 = Image.new("P", (10, 1), 1) + im.paste(im1, (10, 0)) + pattern = Pattern(im, Config(Machine.KH910_KH950, Mode.SINGLEBED), 2) + pattern.alignment = Alignment.CENTER control.pattern = pattern - assert pattern.pat_start_needle == 160 - assert pattern.pat_end_needle == 200 - control.start_needle = 160 - control.end_needle = 200 + assert (pattern.pat_start_needle, pattern.pat_end_needle) == (80, 120) + control.start_needle = 80 + control.end_needle = 120 control.start_pixel = 0 control.end_pixel = 40 - bits0 = bitarray() - bits0.frombytes( - b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + expected = bitarray( + "00000000000000000000000000000000000000000000000000000000000000000000000000000000111111111100000000001111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000" ) - assert control.select_needles_API6(0, 0, False) == bits0 + actual = control.select_needles_API6(0, 0, False) + assert actual == expected def test_row_multiplier(self): assert Mode.SINGLEBED.row_multiplier(2) == 1