test_bag_to_sql.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 """
4 Test: grep input bags to SQL schema output.
5 
6 ------------------------------------------------------------------------------
7 This file is part of grepros - grep for ROS bag files and live topics.
8 Released under the BSD License.
9 
10 @author Erki Suurjaak
11 @created 22.12.2021
12 @modified 24.12.2021
13 ------------------------------------------------------------------------------
14 """
15 import logging
16 import os
17 import sys
18 
19 sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
20 from test import testbase
21 
22 logger = logging.getLogger()
23 
24 
26  """Tests grepping from input bags and writing schema to SQL file."""
27 
28 
29  NAME = os.path.splitext(os.path.basename(__file__))[0]
30 
31 
32  OUTPUT_LABEL = "SQL"
33 
34 
35  OUTPUT_SUFFIX = ".sql"
36 
37  def setUp(self):
38  """Collects bags in data directory, assembles command."""
39  super().setUp()
40  self._cmd = self.CMD_BASE + ["--no-console-output", "--plugin", "grepros.plugins.sql",
41  "--write", self._outname]
42 
43  def test_grepros(self):
44  """Runs grepros on bags in data directory, verifies HTML output."""
45  self.verify_bags()
46  self.run_command()
47  self.assertTrue(os.path.isfile(self._outname), "Expected output file not written.")
48 
49  logger.info("Reading data from written %s.", self.OUTPUT_LABEL)
50  with open(self._outname) as f:
51  fulltext = f.read()
52  self.verify_topics(fulltext)
53 
54 
55 if "__main__" == __name__:
56  TestBagInputSqlOutput.run_rostest()
test.testbase.TestBase
Definition: testbase.py:46
test.test_bag_to_sql.TestBagInputSqlOutput
Definition: test_bag_to_sql.py:25
test.testbase.TestBase.CMD_BASE
list CMD_BASE
Base command for running grepros.
Definition: testbase.py:71
test.test_bag_to_sql.TestBagInputSqlOutput.test_grepros
def test_grepros(self)
Definition: test_bag_to_sql.py:43
test.testbase.TestBase.verify_topics
def verify_topics(self, topics, messages=None)
Definition: testbase.py:176
test.test_bag_to_sql.TestBagInputSqlOutput.setUp
def setUp(self)
Definition: test_bag_to_sql.py:37
test.test_bag_to_sql.TestBagInputSqlOutput._cmd
_cmd
Definition: test_bag_to_sql.py:40
test.testbase.TestBase._outname
_outname
Definition: testbase.py:97
test.testbase.TestBase.verify_bags
def verify_bags(self)
Definition: testbase.py:169
test.testbase.TestBase.run_command
def run_command(self, communicate=True)
Definition: testbase.py:154
test.test_bag_to_sql.TestBagInputSqlOutput.OUTPUT_LABEL
string OUTPUT_LABEL
Name used in logging.
Definition: test_bag_to_sql.py:32


grepros
Author(s): Erki Suurjaak
autogenerated on Sat Jan 6 2024 03:11:29