def test_accepts_disable_ipv4_if_false(self): form = NodeForm( data={ 'architecture': make_usable_architecture(self), 'disable_ipv4': False, }) form.save()
def test_rejects_disable_ipv4_if_true(self): form = NodeForm( data={ 'architecture': make_usable_architecture(self), 'disable_ipv4': True, }) self.assertFalse(form.is_valid())
def test_validates_domain(self): machine = factory.make_Node() patch_usable_architectures(self, [machine.architecture]) form = NodeForm(data={"domain": factory.make_name("domain")}, instance=machine) self.assertFalse(form.is_valid())
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_contains_limited_set_of_fields(self): form = NodeForm() self.assertItemsEqual( ["hostname", "domain", "disable_ipv4", "swap_size"], list(form.fields), )
def test_contains_limited_set_of_fields(self): form = NodeForm() self.assertItemsEqual([ 'hostname', 'domain', 'disable_ipv4', 'swap_size', ], list(form.fields))
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)