def update_list(todo_list): try: result = db_functions.update_list(**todo_list) except TypeError: return False else: return result
def update_list(todo_list): kwargs = {} for child in todo_list: kwargs[child.tag] = child.text try: result = db_functions.update_list(**kwargs) except TypeError: return False else: return result
def test_updating_lists(self): added_data = self.initialize_list() updated_data = [ ('Updated header 1', None, None, None), (None, 'Updated name 2', 0, None), (None, None, None, None), ('Updated header 4', 'Updated name 4', 1, None), ] for i, updated in enumerate(updated_data): db_functions.update_list(i + 1, header=updated[0], author_name=updated[1], type=updated[2], db_name=self.db_name) for i in range(len(updated_data)): updated = () for j in range(len(updated_data[i])): updated += updated_data[i][j] if updated_data[i][ j] is not None else added_data[i][j], updated_data[i] = updated retrieved_data = db_functions.get_all_lists(self.db_name) self.check_lists_equal(updated_data, retrieved_data)
def put_todo_list(list_id): if request.content_type != 'text/xml': # todo it return todo_list = ET.fromstring(request.body.read()) kwargs = {} for child in todo_list: kwargs[child.tag] = child.text try: updated = db_functions.update_list(list_id, **kwargs) except TypeError: # todo right status? response.status = '405 Method Not Allowed' # todo? content-type else: if updated: response.status = '204 No Content' else: response.status = '404 Not Found'
def test_updating_not_existed_list(self): self.assertFalse(db_functions.update_list(1, db_name=self.db_name))