Example #1
0
 def test_post_duplicate_by_name(self):
     do_init_grids('{0}/{1}'.format(self.url, self.service))
     good_responses = copy.deepcopy(GRIDS)
     for good_response in good_responses:
         good_response['status'] = 'Grid with this name already in index'
     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)
Example #2
0
 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)
Example #3
0
 def test_post_duplicate_by_id(self):
     do_init_grids('{0}/{1}'.format(self.url, self.service))
     requests = copy.deepcopy(GRIDS)
     for request in requests:
         request['name'] = ''.join(choice(ascii_letters) for i in range(12))
     good_responses = copy.deepcopy(requests)
     for good_response in good_responses:
         good_response['status'] = 'Grid with this id already in index'
     ret = do_post('{0}/{1}'.format(self.url, self.service), requests)
     self.assertEqual(ret.json().sort(key=lambda item: item['name']),
                      good_responses.sort(key=lambda item: item['name']))
     self.assertEqual(ret.status_code, 200)
Example #4
0
 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)
Example #5
0
 def test_post_cells_duplicate_by_id(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:
         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'] = 'Cell with this id already in index'
         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)
Example #6
0
 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']:
                 cell['grid_id'] = str(uuid.uuid4())
                 request.append(cell)
         good_responses = copy.deepcopy(request)
         for good_response in good_responses:
             good_response['status'] = 'Grid not match'
         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)