summaryrefslogtreecommitdiff
path: root/testrepository/tests/commands
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2012-04-30 21:24:46 +1200
committerRobert Collins <robertc@robertcollins.net>2012-04-30 21:24:46 +1200
commit2b68591efdeb9c8ee6a7b7dcd52aa1818e6e595c (patch)
tree20eba4044b58f6883408ad1e4cd18687b8539d91 /testrepository/tests/commands
parentbb774022e96430bcf1d145c5fff42b074b726ab7 (diff)
downloadtestrepository-2b68591efdeb9c8ee6a7b7dcd52aa1818e6e595c.tar.gz
Glue into the active commands a way to get a customised filter, which the next patch will parameterise with tag stripping support.
Diffstat (limited to 'testrepository/tests/commands')
-rw-r--r--testrepository/tests/commands/test_failing.py19
-rw-r--r--testrepository/tests/commands/test_last.py22
-rw-r--r--testrepository/tests/commands/test_load.py21
3 files changed, 59 insertions, 3 deletions
diff --git a/testrepository/tests/commands/test_failing.py b/testrepository/tests/commands/test_failing.py
index 7b6efab..831f020 100644
--- a/testrepository/tests/commands/test_failing.py
+++ b/testrepository/tests/commands/test_failing.py
@@ -22,7 +22,11 @@ from testtools.matchers import DocTestMatches
from testrepository.commands import failing
from testrepository.ui.model import UI
from testrepository.repository import memory
-from testrepository.tests import ResourcedTestCase, Wildcard
+from testrepository.tests import (
+ ResourcedTestCase,
+ StubTestCommand,
+ Wildcard,
+ )
class TestCommand(ResourcedTestCase):
@@ -135,3 +139,16 @@ class TestCommand(ResourcedTestCase):
self.assertEqual(1, cmd.execute())
self.assertEqual([True], calls)
+ def test_grabs_TestCommand_result(self):
+ ui, cmd = self.get_test_ui_and_cmd()
+ cmd.repository_factory = memory.RepositoryFactory()
+ calls = []
+ cmd.repository_factory.initialise(ui.here)
+ cmd.command_factory = StubTestCommand
+ StubTestCommand.results = []
+ # None, None would be nice here, but sigh, default arguments etc.
+ self.addCleanup(StubTestCommand.results.__delslice__, 0, 100)
+ cmd.execute()
+ self.assertEqual(
+ [('startTestRun',), ('stopTestRun',)],
+ StubTestCommand.results[0]._events)
diff --git a/testrepository/tests/commands/test_last.py b/testrepository/tests/commands/test_last.py
index 2358d64..75ae58c 100644
--- a/testrepository/tests/commands/test_last.py
+++ b/testrepository/tests/commands/test_last.py
@@ -19,7 +19,11 @@ import testtools
from testrepository.commands import last
from testrepository.ui.model import UI
from testrepository.repository import memory
-from testrepository.tests import ResourcedTestCase, Wildcard
+from testrepository.tests import (
+ ResourcedTestCase,
+ StubTestCommand,
+ Wildcard,
+ )
class TestCommand(ResourcedTestCase):
@@ -60,3 +64,19 @@ class TestCommand(ResourcedTestCase):
result.stopTestRun()
self.assertEqual(1, result.testsRun)
self.assertEqual(1, len(result.failures))
+
+ def test_grabs_TestCommand_result(self):
+ ui, cmd = self.get_test_ui_and_cmd()
+ cmd.repository_factory = memory.RepositoryFactory()
+ repo = cmd.repository_factory.initialise(ui.here)
+ inserter = repo.get_inserter()
+ inserter.startTestRun()
+ id = inserter.stopTestRun()
+ cmd.command_factory = StubTestCommand
+ StubTestCommand.results = []
+ # None, None would be nice here, but sigh, default arguments etc.
+ self.addCleanup(StubTestCommand.results.__delslice__, 0, 100)
+ cmd.execute()
+ self.assertEqual(
+ [('startTestRun',), Wildcard, Wildcard, ('stopTestRun',)],
+ StubTestCommand.results[0]._events)
diff --git a/testrepository/tests/commands/test_load.py b/testrepository/tests/commands/test_load.py
index 580602d..7661c64 100644
--- a/testrepository/tests/commands/test_load.py
+++ b/testrepository/tests/commands/test_load.py
@@ -25,7 +25,11 @@ from testtools.tests.helpers import LoggingResult
from testrepository.commands import load
from testrepository.ui.model import UI
-from testrepository.tests import ResourcedTestCase, Wildcard
+from testrepository.tests import (
+ ResourcedTestCase,
+ StubTestCommand,
+ Wildcard,
+ )
from testrepository.tests.test_repository import RecordingRepositoryFactory
from testrepository.tests.repository.test_file import HomeDirTempDir
from testrepository.repository import memory, RepositoryNotFound
@@ -245,3 +249,18 @@ class TestCommandLoad(ResourcedTestCase):
[('summary', False, 2, 1, 6.0, -3.0,
[('id', 1, None), ('failures', 2, 1)])],
ui.outputs[1:])
+
+ def test_grabs_TestCommand_result(self):
+ ui = UI([('subunit', '')])
+ cmd = load.load(ui)
+ ui.set_command(cmd)
+ cmd.repository_factory = memory.RepositoryFactory()
+ cmd.repository_factory.initialise(ui.here)
+ cmd.command_factory = StubTestCommand
+ StubTestCommand.results = []
+ # None, None would be nice here, but sigh, default arguments etc.
+ self.addCleanup(StubTestCommand.results.__delslice__, 0, 100)
+ cmd.execute()
+ self.assertEqual(
+ [('startTestRun',), ('stopTestRun',)],
+ StubTestCommand.results[0]._events)