class TestFurnaceProcessWindowsUpdate(unittest.TestCase): def setUp(self): self.tile = FurnaceTile(0, 0, 0) self.tile2 = FurnaceTile(0, 1, 0) # no any windows self.protocol1 = FakeProtocol() # window with different coordinates self.protocol2 = FakeProtocol() self.protocol2.windows.append(FurnaceWindow(1, Inventory(), self.tile2.inventory, coords2)) # windows with proper coodinates self.protocol3 = FakeProtocol() self.protocol3.windows.append(FurnaceWindow(2, Inventory(), self.tile.inventory, coords)) self.factory = FakeFactory() self.factory.protocols = { 1: self.protocol1, 2: self.protocol2, 3: self.protocol3 } self.process = FurnaceProcess(self.tile, coords) self.process.factory = self.factory def test_slot_update(self): self.process.update_all_windows_slot(1, None) self.process.update_all_windows_slot(2, Slot(blocks['glass'].slot, 0, 13)) self.assertEqual(self.protocol1.write_packet_calls, []) self.assertEqual(self.protocol2.write_packet_calls, []) self.assertEqual(len(self.protocol3.write_packet_calls), 2) self.assertEqual(self.protocol3.write_packet_calls[0], (('window-slot',), {'wid': 2, 'slot': 1, 'primary': -1})) self.assertEqual(self.protocol3.write_packet_calls[1], (('window-slot',), {'wid': 2, 'slot': 2, 'primary': 20, 'secondary': 0, 'count': 13})) def test_bar_update(self): self.process.update_all_windows_progress(0, 55) self.assertEqual(self.protocol1.write_packet_calls, []) self.assertEqual(self.protocol2.write_packet_calls, []) self.assertEqual(self.protocol3.write_packet_calls, [(('window-progress',), {'wid': 2, 'bar': 0, 'progress': 55})])