def test_edit_via_form(self): """You can add regular IP address via form.""" other_address = IPAddressFactory() other_address.save() data = { 'ip': 'Save', 'ip-0-address': self.regular_ipaddr.address, 'ip-0-hostname': self.regular_ipaddr.hostname, 'ip-0-id': self.regular_ipaddr.id, 'ip-1-address': other_address.address, 'ip-1-hostname': 'hostname.dc1', 'ip-1-id': '', 'ip-INITIAL_FORMS': '1', 'ip-TOTAL_FORMS': '2', } self.client.post(self.url, data) other_address = IPAddress.objects.get(pk=other_address.pk) self.assertEquals(other_address.hostname, 'hostname.dc1') self.assertIn(other_address, self.device.ipaddress_set.all())
def test_try_edit_management_via_form(self): """You can't add management IP address via form.""" other_address = IPAddressFactory(is_management=True) other_address.save() data = { 'ip': 'Save', 'ip-0-address': self.regular_ipaddr.address, 'ip-0-hostname': self.regular_ipaddr.hostname, 'ip-0-id': self.regular_ipaddr.id, 'ip-1-address': other_address.address, 'ip-1-hostname': 'hostname.dc1', 'ip-1-id': '', 'ip-INITIAL_FORMS': '1', 'ip-TOTAL_FORMS': '2', } response = self.client.post(self.url, data) self.assertContains( response, 'To assign management IP to this device use the linked asset') self.assertNotIn(other_address, self.device.ipaddress_set.all())
def test_try_edit_management_via_form(self): """You can't add management IP address via form.""" other_address = IPAddressFactory(is_management=True) other_address.save() data = { 'ip': 'Save', 'ip-0-address': self.regular_ipaddr.address, 'ip-0-hostname': self.regular_ipaddr.hostname, 'ip-0-id': self.regular_ipaddr.id, 'ip-1-address': other_address.address, 'ip-1-hostname': 'hostname.dc1', 'ip-1-id': '', 'ip-INITIAL_FORMS': '1', 'ip-TOTAL_FORMS': '2', } response=self.client.post(self.url, data) self.assertContains( response, 'To assign management IP to this device use the linked asset' ) self.assertNotIn(other_address, self.device.ipaddress_set.all())