def test_lookup_hm_port(self):
    nc = mock.MagicMock()
    nc.list_ports.return_value = {'ports': ['first', 'second']}
    with self.assertRaises(api_crud.DuplicateResource):
        api_crud.lookup_hm_port(nc, 'fake-unit-name')
    nc.list_ports.return_value = {'ports': ['first']}
    self.assertEquals(api_crud.lookup_hm_port(nc, 'fake-unit-name'), 'first')
    nc.list_ports.return_value = {}
    self.assertEquals(api_crud.lookup_hm_port(nc, 'fake-unit-name'), None)
def test_lookup_hm_port(self):
    nc = mock.MagicMock()
    nc.list_ports.return_value = {'ports': ['first', 'second']}
    with self.assertRaises(api_crud.DuplicateResource):
        api_crud.lookup_hm_port(nc, 'fake-unit-name')
    nc.list_ports.return_value = {'ports': ['first']}
    self.assertEquals(api_crud.lookup_hm_port(nc, 'fake-unit-name'), 'first')
    nc.list_ports.return_value = {}
    self.assertEquals(api_crud.lookup_hm_port(nc, 'fake-unit-name'), None)