xfstestsdb/tests/testcase/test_testcase.py
Anna Schumaker 489c08e55c testcase: Create the xfstestsdb testcase list command
This command prints out information about the known testcases. It has
extra options to filter by runid, device, xunit, testcase, and status.

Implements: #11 (`xfstestsdb testcase list`)
Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
2023-02-16 16:15:56 -05:00

32 lines
1.2 KiB
Python

# Copyright 2023 (c) Anna Schumaker.
"""Tests the `xfstestsdb testcase` command."""
import argparse
import io
import unittest
import unittest.mock
import xfstestsdb
class TestTestcase(unittest.TestCase):
"""Tests the `xfstestsdb testcase` command."""
def setUp(self):
"""Set up common variables."""
self.xfstestsdb = xfstestsdb.Command()
self.testcase = self.xfstestsdb.commands["testcase"]
def test_init(self):
"""Check that the testcase command was set up properly."""
self.assertIsInstance(self.testcase, xfstestsdb.commands.Command)
self.assertIsInstance(self.testcase, xfstestsdb.testcase.Command)
self.assertIsInstance(self.testcase.subparser, argparse.Action)
self.assertEqual(self.xfstestsdb.subparser.choices["testcase"],
self.testcase.parser)
@unittest.mock.patch("sys.stdout", new_callable=io.StringIO)
def test_xunit_empty(self, mock_stdout: io.StringIO):
"""Test calling `xfstestdb xunit` with an empty argument list."""
self.xfstestsdb.run(["testcase"])
self.assertRegex(mock_stdout.getvalue(),
r"^usage: .*? testcase \[\-h\] \{.*?} ...$")