def put(self, database, table, rowid=None): """REPLACE record""" if not rowid: raise HTTPError(405) # We need a rowid to use REPLACE obj = loads(self.request.body) try: db.replace_record(database, table, rowid, obj) except db.NoSuchDatabase: raise HTTPError(404)
def test_replace_record(self): # TODO: define behavior for when a record does not exist id = db.insert_record(TEST_DB, TEST_TABLE, col1=123, col2='abc') db.replace_record(TEST_DB, TEST_TABLE, id, [555, 'def']) res = db.get_record(TEST_DB, TEST_TABLE, id) self.assertEqual(res, {'rowid': id, 'col1': 555, 'col2': 'def'})
def test_replace_record(self): # TODO: define behavior for when a record does not exist id = db.insert_record(TEST_DB,TEST_TABLE,col1=123,col2='abc') db.replace_record(TEST_DB,TEST_TABLE,id,[555,'def']) res = db.get_record(TEST_DB,TEST_TABLE,id) self.assertEqual(res, {'rowid':id,'col1':555,'col2':'def'})