def test_share_server_delete_with_details(self): server = self._create_share_server() details = { 'value1': '1', 'value2': '2', } db.share_server_backend_details_set(self.ctxt, server['id'], details) num_records = len(db.share_server_get_all(self.ctxt)) db.share_server_delete(self.ctxt, server['id']) self.assertEqual(len(db.share_server_get_all(self.ctxt)), num_records - 1)
def test_share_server_backend_details_set(self): details = { 'value1': '1', 'value2': '2', } server = self._create_share_server() db.share_server_backend_details_set(self.ctxt, server['id'], details) self.assertDictMatch( details, db.share_server_backend_details_get(self.ctxt, server['id']))
def _create_share_server(state='new', share_network_id=None, host=None): """Create a share server object.""" srv = {} srv['host'] = host srv['share_network_id'] = share_network_id srv['status'] = state share_srv = db.share_server_create(context.get_admin_context(), srv) backend_details = {'fake': 'fake'} db.share_server_backend_details_set(context.get_admin_context(), share_srv['id'], backend_details) return db.share_server_get(context.get_admin_context(), share_srv['id'])
def test_share_server_backend_details_set(self): details = { 'value1': '1', 'value2': '2', } server = self._create_share_server() db.share_server_backend_details_set(self.ctxt, server['id'], details) self.assertDictMatch( details, db.share_server_get(self.ctxt, server['id'])['backend_details'] )
def create_share_server(**kwargs): """Create a share server object.""" backend_details = kwargs.pop('backend_details', {}) srv = { 'host': 'host1', 'share_network_id': 'fake_srv_id', 'status': constants.STATUS_ACTIVE } share_srv = _create_db_row(db.share_server_create, srv, kwargs) if backend_details: db.share_server_backend_details_set(context.get_admin_context(), share_srv['id'], backend_details) return db.share_server_get(context.get_admin_context(), share_srv['id'])
def test_share_server_delete_with_details(self): server = self._create_share_server() details = { 'value1': '1', 'value2': '2', } db.share_server_backend_details_set(self.ctxt, server['id'], details) num_records = len(db.share_server_get_all(self.ctxt)) db.share_server_delete(self.ctxt, server['id']) self.assertEqual(len(db.share_server_get_all(self.ctxt)), num_records - 1) self.assertFalse( db.share_server_backend_details_get(self.ctxt, server['id']))
def _create_share_server(state='ACTIVE', share_network_id=None, host=None): """Create a share server object.""" srv = {} srv['host'] = host srv['share_network_id'] = share_network_id srv['status'] = state share_srv = db.share_server_create(context.get_admin_context(), srv) backend_details = {'fake': 'fake'} db.share_server_backend_details_set(context.get_admin_context(), share_srv['id'], backend_details) return db.share_server_get(context.get_admin_context(), share_srv['id'])
def create_share_server(**kwargs): """Create a share server object.""" backend_details = kwargs.pop('backend_details', {}) srv = { 'host': 'host1', 'share_network_id': 'fake_srv_id', 'status': constants.STATUS_ACTIVE } share_srv = _create_db_row(db.share_server_create, srv, kwargs) if backend_details: db.share_server_backend_details_set( context.get_admin_context(), share_srv['id'], backend_details) return db.share_server_get(context.get_admin_context(), share_srv['id'])
def test_share_server_get_with_details(self): values = { 'share_network_id': 'fake-share-net-id', 'host': 'hostname', 'status': 'ACTIVE' } details = { 'value1': '1', 'value2': '2', } srv_id = self._create_share_server(values)['id'] db.share_server_backend_details_set(self.ctxt, srv_id, details) server = db.share_server_get(self.ctxt, srv_id) self.assertEqual(srv_id, server['id']) self.assertEqual(server.share_network_id, values['share_network_id']) self.assertEqual(server.host, values['host']) self.assertEqual(server.status, values['status']) self.assertDictMatch(details, server['backend_details'])