async def test_update(self): key = "1" new_record = Record(key, data={"features": {"by_ten": 10}}) async with self.post(f"/source/{self.slabel}/update/{key}", json=new_record.export()) as r: self.assertEqual(await r.json(), OK) self.assertEqual((await self.sctx.record(key)).feature("by_ten"), 10)
async def record(self, key: str): # Create a blank record in case it doesn't exist within the source record = Record(key) # Execute the query to get a single record from a key await self.conn.execute(self.parent.config.record, (key,)) # Retrieve the result row = await self.conn.fetchone() # Convert it to a record if it exists and populate the previously blank # record by merging the two if row is not None: record.merge(self.row_to_record(row)) self.logger.debug("Got: %s: %r", record.key, record.export()) return record