def test_get_empty_base(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) do_init_cells('{0}/{1}'.format(self.url, self.service)) do_delete('{0}/{1}'.format(self.url, self.service)) ret = do_get('{0}/{1}'.format(self.url, self.service)) self.assertEqual(ret.json(), []) self.assertEqual(ret.status_code, 200)
def test_post_grids(self): do_delete('{0}/{1}'.format(self.url, self.service)) good_responses = copy.deepcopy(GRIDS) for good_response in good_responses: good_response['status'] = 'created' ret = do_post("{0}/{1}".format(self.url, self.service), GRIDS) self.assertEqual(ret.json().sort(key=lambda item: item['name']), good_responses.sort(key=lambda item: item['name'])) self.assertEqual(ret.status_code, 200)
def test_get_empty_base_for_grid(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) do_init_cells('{0}/{1}'.format(self.url, self.service)) do_delete('{0}/{1}'.format(self.url, self.service)) for grid in GRIDS: ret = do_get('{0}/{1}/{2}'.format(self.url, self.service, grid['id'])) self.assertEqual(ret.json(), []) self.assertEqual(ret.status_code, 200)
def test_post_cells_grid_not_found(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) do_init_cells('{0}/{1}'.format(self.url, self.service)) do_delete('{0}/{1}'.format(self.url, self.service)) for grid in GRIDS: request = [] for cell in CELLS: if cell['grid_id'] == grid['id']: request.append(cell) ret = do_post( "{0}/{1}/{2}".format(self.url, self.service, str(uuid.uuid4())), request) self.assertEqual(ret.json(), 'Not found') self.assertEqual(ret.status_code, 404)
def test_delete_for_grid_not_found(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) do_init_cells('{0}/{1}'.format(self.url, self.service)) for i in range(10): ret = do_delete('{0}/{1}/{2}'.format(self.url, self.service, str(uuid.uuid4()))) self.assertEqual(ret.json(), 'Not found') self.assertEqual(ret.status_code, 404)
def test_post_cells(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) do_init_cells('{0}/{1}'.format(self.url, self.service)) do_delete('{0}/{1}'.format(self.url, self.service)) for grid in GRIDS: request = [] for cell in CELLS: if cell['grid_id'] == grid['id']: request.append(cell) good_responses = copy.deepcopy(request) for good_response in good_responses: good_response['status'] = 'created' ret = do_post( "{0}/{1}/{2}".format(self.url, self.service, grid['id']), request) self.assertEqual(ret.json().sort(key=lambda item: item['id']), good_responses.sort(key=lambda item: item['id'])) self.assertEqual(ret.status_code, 200)
def test_delete_grids(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) requests = copy.deepcopy(GRIDS) good_responses = copy.deepcopy(requests) for good_response in good_responses: good_response['status'] = 'deleted' for request in requests: good_response = do_search('id', request['id'], good_responses) ret = do_delete('{0}/{1}/{2}'.format(self.url, self.service, request['id'])) self.assertEqual(ret.json(), good_response) self.assertEqual(ret.status_code, 200)
def test_delete_base(self): do_init_grids('{0}/{1}'.format(self.url, self.service)) ret = do_delete('{0}/{1}'.format(self.url, self.service)) self.assertEqual(ret.json(), DELETE_INDEX_RESPONSE) self.assertEqual(ret.status_code, 200)