def test_init(self): net.Network(uuid='notauuid', vxlan_id=42, provide_dhcp=True, provide_nat=True, physical_nic='eth0', ipblock='192.168.1.0/24')
def test_is_okay_no_dns(self, mock_is_dnsmasq, mock_is_created): n = net.Network(uuid='actualuuid', vxlan_id=42, provide_dhcp=True, provide_nat=True, physical_nic='eth0', ipblock='192.168.1.0/24') self.assertTrue(n.is_okay())
def test_str(self): n = net.Network(uuid='notauuid', vxlan_id=42, provide_dhcp=True, provide_nat=True, physical_nic='eth0', ipblock='192.168.1.0/24') self.assertEqual('network(notauuid, vxid 42)', str(n))
def test_is_created_no_bridge(self, mock_execute): n = net.Network(uuid='1111111-d923-4441-b498-4f8e3c166804', vxlan_id=111, provide_dhcp=True, provide_nat=True, physical_nic='eth0', ipblock='192.168.1.0/24') self.assertFalse(n.is_created())
def test_is_created_yes(self, mock_execute): n = net.Network(uuid='8abbc9a6-d923-4441-b498-4f8e3c166804', vxlan_id=5, provide_dhcp=True, provide_nat=True, physical_nic='eth0', ipblock='192.168.1.0/24') self.assertTrue(n.is_created())
def test_init(self): net.Network({ 'uuid': 'notauuid', 'vxid': 42, 'provide_dhcp': True, 'provide_nat': True, 'physical_nic': 'eth0', 'netblock': '192.168.1.0/24' })
def test_is_okay_no_dns(self, mock_is_dnsmasq, mock_is_created): n = net.Network({ 'uuid': 'actualuuid', 'vxid': 42, 'provide_dhcp': True, 'provide_nat': True, 'physical_nic': 'eth0', 'netblock': '192.168.1.0/24' }) self.assertTrue(n.is_okay())
def test_str(self): n = net.Network({ 'uuid': 'notauuid', 'vxid': 42, 'provide_dhcp': True, 'provide_nat': True, 'physical_nic': 'eth0', 'netblock': '192.168.1.0/24' }) self.assertEqual('network(notauuid, vxid 42)', str(n))
def test_is_created_no_bridge(self, mock_execute): n = net.Network({ 'uuid': '1111111-d923-4441-b498-4f8e3c166804', 'vxid': 5, 'provide_dhcp': True, 'provide_nat': True, 'physical_nic': 'eth0', 'netblock': '192.168.1.0/24' }) self.assertFalse(n.is_created())
def test_is_okay_not_created(self, mock_is_dnsmasq, mock_is_created): n = net.Network({ 'uuid': 'actualuuid', 'vxid': 42, 'name': 'bobnet', 'namespace': 'finitespace', 'provide_dhcp': True, 'provide_nat': True, 'egress_nic': 'eth0', 'mesh_nic': 'eth0', 'netblock': '192.168.1.0/24' }) self.assertFalse(n.is_okay())
def test_str(self): n = net.Network({ 'uuid': 'notauuid', 'vxid': 42, 'name': 'bobnet', 'namespace': 'finitespace', 'provide_dhcp': True, 'provide_nat': True, 'egress_nic': 'eth0', 'mesh_nic': 'eth0', 'netblock': '192.168.1.0/24' }) self.assertEqual('network(notauuid)', str(n))
def test_init(self): net.Network({ 'uuid': 'notauuid', 'vxid': 2, 'name': 'bobnet', 'namespace': 'finitespace', 'provide_dhcp': True, 'provide_nat': True, 'egress_nic': 'eth0', 'mesh_nic': 'eth0', 'mesh_nic': 'eth0', 'netblock': '192.168.1.0/24' })
def test_is_created_no_bridge(self, mock_execute): n = net.Network({ 'uuid': '8abbc9a6-d923-4441-b498-4f8e3c166804', 'vxid': 5, 'name': 'bobnet', 'namespace': 'finitespace', 'provide_dhcp': True, 'provide_nat': True, 'egress_nic': 'eth0', 'mesh_nic': 'eth0', 'netblock': '192.168.1.0/24' }) self.assertFalse(n.is_created())
def test_set_state_valid( self, mock_put, mock_attribute_set, mock_state_get, mock_lock): n = net.Network({ 'uuid': '8abbc9a6-d923-4441-b498-4f8e3c166804', 'vxid': 5, 'name': 'bobnet', 'namespace': 'finitespace', 'provide_dhcp': True, 'provide_nat': True, 'egress_nic': 'eth0', 'mesh_nic': 'eth0', 'netblock': '192.168.1.0/24' }) with testtools.ExpectedException(exceptions.InvalidStateException): n.state = net.Network.STATE_INITIAL n.state = dbo.STATE_ERROR n.state = dbo.STATE_DELETED with testtools.ExpectedException(exceptions.InvalidStateException): n.state = dbo.STATE_CREATED
def test_delete_all_networks(self, mock_db_get_lock, mock_etcd_put, mock_update_network_state, mock_delete, mock_remove_dhcp, mock_get_ipmanager, mock_db_get_network_interfaces, mock_db_get_networks): mock_network = mock.patch('shakenfist.net.from_db', return_value=net.Network({'uuid': 'foo'})) mock_network.start() self.addCleanup(mock_network.stop) resp = self.client.delete('/networks', headers={'Authorization': self.auth_header}, data=json.dumps({ 'confirm': True, 'namespace': 'foo' })) self.assertEqual(['30f6da44-look-i-am-uuid'], resp.get_json()) self.assertEqual(200, resp.status_code) mock_network.stop()