def test_get_filled_base(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) do_init_cells('{0}/{1}'.format(self.url, self.service)) ret = do_get('{0}/{1}'.format(self.url, self.service)) self.assertEqual(ret.json().sort(key=lambda item: item['id']), CELLS.sort(key=lambda item: item['id'])) self.assertEqual(ret.status_code, 200)
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_get_grids(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) good_responses = copy.deepcopy(GRIDS) for good_response in good_responses: ret = do_get('{0}/{1}/{2}'.format(self.url, self.service, good_response['id'])) self.assertEqual(ret.json(), good_response) 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_get_filled_base_for_grid(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) do_init_cells('{0}/{1}'.format(self.url, self.service)) for grid in GRIDS: ret = do_get('{0}/{1}/{2}'.format(self.url, self.service, grid['id'])) good_response = [] for cell in CELLS: if cell['grid_id'] == grid['id']: good_response.append(cell) self.assertEqual(ret.json().sort(key=lambda item: item['id']), good_response.sort(key=lambda item: item['id'])) self.assertEqual(ret.status_code, 200)
def test_get_filled_base(self): do_init_grids('{0}/{1}'.format(self.url, self.service)) ret = do_get('{0}/{1}'.format(self.url, self.service)) self.assertEqual(ret.json().sort(key=lambda item: item['name']), GRIDS.sort(key=lambda item: item['name'])) self.assertEqual(ret.status_code, 200)
def test_get_grid_not_found(self): do_init_grids('{0}/{1}'.format(self.url, str('grids'))) for i in range(10): ret = do_get('{0}/{1}/{2}'.format(self.url, self.service, str(uuid.uuid4()))) self.assertEqual(ret.json(), str('Not found')) self.assertEqual(ret.status_code, 404)