def test_sync_successful(self, mock_port_create, mock_port_update, mock_port_del, mock_port_get_all, mock_list_ports, get_lock): port_obj = resources.StoragePortTask( context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda') port_obj.sync() self.assertTrue(mock_list_ports.called) self.assertTrue(mock_port_get_all.called) self.assertTrue(get_lock.called) # collect the ports from fake_storage fake_storage_obj = fake_storage.FakeStorageDriver() # add the ports to DB mock_list_ports.return_value = fake_storage_obj.list_ports(context) mock_port_get_all.return_value = list() port_obj.sync() self.assertTrue(mock_port_create.called) # update the ports to DB mock_list_ports.return_value = ports_list mock_port_get_all.return_value = ports_list port_obj.sync() self.assertTrue(mock_port_update.called) # delete the ports to DB mock_list_ports.return_value = list() mock_port_get_all.return_value = ports_list port_obj.sync() self.assertTrue(mock_port_del.called)
def test_remove(self, mock_port_del): port_obj = resources.StoragePortTask( context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda') port_obj.remove() self.assertTrue(mock_port_del.called)