[tracker/wip/carlosg/more-tests: 3/12] tests: Add some bogus CLI tests
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/more-tests: 3/12] tests: Add some bogus CLI tests
- Date: Tue, 29 Sep 2020 13:51:10 +0000 (UTC)
commit 7bc920c28529349ba3466a99773a1bab4b5ea61a
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Sep 10 19:31:38 2020 +0200
tests: Add some bogus CLI tests
Test no-args CLI calls, and "tracker help". We don't do a lot to test
it, mostly check there's some output and it doesn't blow up.
tests/functional-tests/cli.py | 14 ++++++++++++++
tests/functional-tests/fixtures.py | 4 ++--
2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/tests/functional-tests/cli.py b/tests/functional-tests/cli.py
index 76ee55c16..62e6e52da 100644
--- a/tests/functional-tests/cli.py
+++ b/tests/functional-tests/cli.py
@@ -82,6 +82,20 @@ class TestCli(fixtures.TrackerCommandLineTestCase):
self.run_cli(
['tracker3', 'import', '--database', tmpdir, testdata]);
+ def test_noargs(self):
+ """Run various commands without arguments."""
+ output = self.run_cli(['tracker3']);
+ self.assertTrue(len (output.splitlines()) > 0)
+
+ self.run_cli(['tracker3', 'import'], 1);
+ self.run_cli(['tracker3', 'export'], 1);
+ self.run_cli(['tracker3', 'sparql'], 1);
+ self.run_cli(['tracker3', 'sql'], 1);
+ self.run_cli(['tracker3', 'endpoint'], 1);
+
+ def test_help(self):
+ output = self.run_cli(['tracker3', 'help', 'import']);
+ self.assertTrue(len (output.splitlines()) > 0)
if __name__ == '__main__':
fixtures.tracker_test_main()
diff --git a/tests/functional-tests/fixtures.py b/tests/functional-tests/fixtures.py
index 08d16da17..c99fc0bbe 100644
--- a/tests/functional-tests/fixtures.py
+++ b/tests/functional-tests/fixtures.py
@@ -173,7 +173,7 @@ class TrackerCommandLineTestCase(ut.TestCase):
test_data = pathlib.Path(__file__).parent.joinpath('test-data')
return test_data.joinpath(filename)
- def run_cli(self, command):
+ def run_cli(self, command, expectedReturnCode=0):
command = [str(c) for c in command]
log.info("Running: %s", ' '.join(command))
result = subprocess.run(command, stdout=subprocess.PIPE,
@@ -184,7 +184,7 @@ class TrackerCommandLineTestCase(ut.TestCase):
if len(result.stderr) > 0:
log.debug("stderr: %s", result.stderr)
- if result.returncode != 0:
+ if result.returncode != expectedReturnCode:
raise CliError('\n'.join([
"CLI command failed.",
"Command: %s" % ' '.join(command),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]