def test_toggle_hm_port(self):
    self.patch_object(api_crud, 'session_from_identity_service')
    self.patch_object(api_crud, 'init_neutron_client')
    identity_service = mock.MagicMock()
    nc = mock.MagicMock()
    self.init_neutron_client.return_value = nc
    nc.list_ports.return_value = {'ports': [{'id': 'fake-port-uuid'}]}
    api_crud.toggle_hm_port(identity_service, 'fake-unit-name')
    self.init_neutron_client.assert_called_once_with(self.session_from_identity_service())
    nc.list_ports.asssert_called_with(tags='charm-octavia-fake-unit-name')
    nc.update_port.assert_called_with('fake-port-uuid', {'port': {'admin_state_up': True}})
def test_toggle_hm_port(self):
    self.patch_object(api_crud, 'session_from_identity_service')
    self.patch_object(api_crud, 'init_neutron_client')
    identity_service = mock.MagicMock()
    nc = mock.MagicMock()
    self.init_neutron_client.return_value = nc
    nc.list_ports.return_value = {'ports': [{'id': 'fake-port-uuid'}]}
    api_crud.toggle_hm_port(identity_service, 'fake-unit-name')
    self.init_neutron_client.assert_called_once_with(self.session_from_identity_service())
    nc.list_ports.asssert_called_with(tags='charm-octavia-fake-unit-name')
    nc.update_port.assert_called_with('fake-port-uuid', {'port': {'admin_state_up': True}})