def test_accepts_domain_by_id(self): machine = factory.make_Node() domain = factory.make_Domain() patch_usable_architectures(self, [machine.architecture]) form = NodeForm(data={"domain": domain.id}, instance=machine) form.save() self.assertEqual(domain.name, machine.domain.name)
def test_accepts_hostname(self): machine = factory.make_Node() hostname = factory.make_string() patch_usable_architectures(self, [machine.architecture]) form = NodeForm(data={ 'hostname': hostname, 'architecture': make_usable_architecture(self), }, instance=machine) form.save() self.assertEqual(hostname, machine.hostname)
def test_NodeForm_changes_node(self): node = factory.make_node() hostname = factory.getRandomString() after_commissioning_action = factory.getRandomChoice( NODE_AFTER_COMMISSIONING_ACTION_CHOICES) form = NodeForm( data={ 'hostname': hostname, 'after_commissioning_action': after_commissioning_action, 'architecture': factory.getRandomChoice(ARCHITECTURE_CHOICES), }, instance=node) form.save() self.assertEqual(hostname, node.hostname) self.assertEqual( after_commissioning_action, node.after_commissioning_action)