4 Test: grep input bags to SQLite output.
6 ------------------------------------------------------------------------------
7 This file is part of grepros - grep for ROS bag files and live topics.
8 Released under the BSD License.
13 ------------------------------------------------------------------------------
20 sys.path.insert(0, os.path.join(os.path.dirname(__file__),
".."))
21 from test
import testbase
23 logger = logging.getLogger()
27 """Tests grepping from input bags and writing matches to SQLite file."""
30 NAME = os.path.splitext(os.path.basename(__file__))[0]
33 OUTPUT_LABEL =
"SQLite"
36 OUTPUT_SUFFIX =
".sqlite"
39 """Collects bags in data directory, assembles command."""
44 """Runs grepros on bags in data directory, verifies SQLite output."""
47 self.assertTrue(os.path.isfile(self.
_outname),
"Expected output file not written.")
49 logger.info(
"Reading data from written %s.", self.
OUTPUT_LABEL)
51 db.row_factory =
lambda cursor, row: dict(sqlite3.Row(cursor, row))
53 for msg
in db.execute(
"SELECT * FROM messages").fetchall():
54 messages.setdefault(msg[
"topic"], []).append(msg)
57 fulltext =
"\n".join(str(m)
for mm
in messages.values()
for m
in mm)
61 if "__main__" == __name__:
62 TestBagInputSqliteOutput.run_rostest()