2 from unittest
import mock
4 from mozperftest
.test
.functionaltestrunner
import (
5 FunctionalTestProcessor
,
10 def test_functionaltestrunner_pass():
11 with mock
.patch("moztest.resolve.TestResolver") as test_resolver_mock
, mock
.patch(
12 "mozperftest.test.functionaltestrunner.load_class_from_path"
13 ) as load_class_path_mock
, mock
.patch(
14 "mozperftest.test.functionaltestrunner.FunctionalTestProcessor"
16 "mozperftest.test.functionaltestrunner.mozlog"
18 test_mock
= mock
.MagicMock()
19 test_mock
.test
.return_value
= 0
20 load_class_path_mock
.return_value
= test_mock
22 mach_cmd
= mock
.MagicMock()
23 test_resolver_mock
.resolve_metadata
.return_value
= (1, 1)
24 mach_cmd
._spawn
.return_value
= test_resolver_mock
26 status
, _
= FunctionalTestRunner
.test(mach_cmd
, [], [])
31 def test_functionaltestrunner_missing_test_failure():
32 with mock
.patch("moztest.resolve.TestResolver") as test_resolver_mock
:
33 mach_cmd
= mock
.MagicMock()
34 test_resolver_mock
.resolve_metadata
.return_value
= (0, 0)
35 mach_cmd
._spawn
.return_value
= test_resolver_mock
36 status
, _
= FunctionalTestRunner
.test(mach_cmd
, [], [])
40 def test_functionaltestrunner_perfmetrics_parsing():
41 formatter_mock
= mock
.MagicMock()
42 formatter_mock
.return_value
= "perfMetrics | fake-data"
44 log_processor
= FunctionalTestProcessor(stream
=sys
.stdout
, formatter
=formatter_mock
)
47 assert len(log_processor
.match
) == 1
50 def test_functionaltestrunner_perfmetrics_missing():
51 formatter_mock
= mock
.MagicMock()
52 formatter_mock
.return_value
= "perfmetrics | fake-data"
54 log_processor
= FunctionalTestProcessor(stream
=sys
.stdout
, formatter
=formatter_mock
)
57 assert len(log_processor
.match
) == 0