def test_find_existing_keeps_type(self): node_type = random.choice( (NODE_TYPE.RACK_CONTROLLER, NODE_TYPE.REGION_AND_RACK_CONTROLLER)) node = factory.make_Node(node_type=node_type) register(system_id=node.system_id) self.assertEqual(node_type, node.node_type)
def test_finds_existing_node_by_system_id(self): node = factory.make_Node() rack_registered = register(system_id=node.system_id) self.assertEqual(node.system_id, rack_registered.system_id)
def test_finds_existing_node_by_hostname(self): node = factory.make_Node() rack_registered = register(hostname=node.hostname) self.assertEqual(node.system_id, rack_registered.system_id)
def test_sets_owner_to_worker_when_none(self): node = factory.make_Node() rack_registered = register(system_id=node.system_id) self.assertEqual(worker_user.get_worker_user(), rack_registered.owner)
def test_leaves_owner_when_owned(self): user = factory.make_User() node = factory.make_Machine(owner=user) rack_registered = register(system_id=node.system_id) self.assertEqual(user, rack_registered.owner)
def test_always_has_current_commissioning_script_set(self): hostname = factory.make_name('hostname') register(hostname=hostname) rack = RackController.objects.get(hostname=hostname) self.assertIsNotNone(rack.current_commissioning_script_set)
def test_converts_existing_node(self): node = factory.make_Node(node_type=NODE_TYPE.MACHINE) rack_registered = register(system_id=node.system_id) self.assertEqual(rack_registered.node_type, NODE_TYPE.RACK_CONTROLLER)
def test_converts_region_controller(self): node = factory.make_Node(node_type=NODE_TYPE.REGION_CONTROLLER) rack_registered = register(system_id=node.system_id) self.assertEqual(rack_registered.node_type, NODE_TYPE.REGION_AND_RACK_CONTROLLER)
def test_sets_version_of_controller(self): version = "1.10.2" node = factory.make_Node(node_type=NODE_TYPE.MACHINE) register(system_id=node.system_id, version=version) self.assertEquals(version, node.as_rack_controller().version)
def test_converts_existing_node(self): node = factory.make_Machine() rack_registered = register(system_id=node.system_id) self.assertEqual(rack_registered.node_type, NODE_TYPE.RACK_CONTROLLER) reload_object(node) self.assertTrue(node.as_rack_controller()._was_probably_machine())