def test_add_high_chip_with_down(self): down_chips = set() down_chips.add((1, 1)) vm = VirtualMachine(2, 2, down_chips=down_chips) self.assertEqual(3, vm.n_chips) _chip = self._create_chip(2, 2) vm.add_chip(_chip) self.assertEqual(vm.max_chip_x, 2) self.assertEqual(vm.max_chip_y, 2) self.assertEqual(4, vm.n_chips) self.assertTrue(vm.is_chip_at(2, 2)) _good = vm.get_chip_at(2, 2) self.assertEqual(_chip, _good) _bad = vm.get_chip_at(2, 1) self.assertIsNone(_bad) _down = vm.get_chip_at(1, 1) self.assertIsNone(_down) count = 0 for _chip in vm.chips: count += 1 self.assertTrue(4, count)
def test_add__chip(self): vm = VirtualMachine(2, 2) _chip = self._create_chip(2, 2) vm.add_chip(_chip) self.assertEqual(vm.max_chip_x, 2) self.assertEqual(vm.max_chip_y, 2) self.assertEqual(5, vm.n_chips) self.assertTrue(vm.is_chip_at(2, 2)) _good = vm.get_chip_at(2, 2) self.assertEqual(_chip, _good) _bad = vm.get_chip_at(2, 1) self.assertIsNone(_bad) count = 0 for _chip in vm.chips: count += 1 self.assertTrue(5, count)
def test_add_existing_chip(self): vm = VirtualMachine(2, 2) _chip = self._create_chip(1, 1) with self.assertRaises(SpinnMachineAlreadyExistsException): vm.add_chip(_chip)