def test_cells_get_all_filter_name(self): for cell in cells: dbapi.cells_create(self.context, cell) setup_res, _ = dbapi.cells_get_all(self.context, {}, default_pagination) self.assertGreater(len(setup_res), 2) filters = { "name": cell1["name"], } res, _ = dbapi.cells_get_all(self.context, filters, default_pagination) self.assertEqual(len(res), 2) for cell in res: self.assertEqual(cell['name'], 'cell1')
def test_cells_get_all_filter_id(self): for cell in cells: dbapi.cells_create(self.context, cell) setup_res, _ = dbapi.cells_get_all(self.context, {}, default_pagination) self.assertGreater(len(setup_res), 2) self.assertEqual(len([cell for cell in setup_res if cell['id'] == 1]), 1) filters = { "id": 1, } res, _ = dbapi.cells_get_all(self.context, filters, default_pagination) self.assertEqual(len(res), 1) self.assertEqual(res[0]['id'], 1)
def test_cells_get_all(self): dbapi.cells_create(self.context, cell1) filters = { "region_id": cell1["region_id"], } res, _ = dbapi.cells_get_all(self.context, filters, default_pagination) self.assertEqual(len(res), 1) self.assertEqual(res[0]['name'], 'cell1')
def test_cells_get_all_with_filters_noexist(self): res = dbapi.cells_create(self.context, cell1) variables = {"key1": "value1", "key2": "value2"} dbapi.variables_update_by_resource_id(self.context, "cells", res.id, variables) filters = {} filters["vars"] = "key2:value5" res, _ = dbapi.cells_get_all(self.context, filters, default_pagination) self.assertEqual(len(res), 0)
def test_cells_get_all_with_filters(self): res = dbapi.cells_create(self.context, cell1) variables = {"key1": "value1", "key2": "value2"} dbapi.variables_update_by_resource_id(self.context, "cells", res.id, variables) filters = { "vars": "key2:value2", "region_id": cell1["region_id"], } res, _ = dbapi.cells_get_all(self.context, filters, default_pagination) self.assertEqual(len(res), 1) self.assertEqual(res[0]['name'], 'cell1')
def test_cells_get_all(self): dbapi.cells_create(self.context, cell1) res = dbapi.cells_get_all(self.context, cell1['region_id']) self.assertEqual(len(res), 1) self.assertEqual(res[0]['name'], 'cell1')