Exemplo n.º 1
0
 def test_main_with_failures(self, mock_exit, mock_find_test):
     tmp_file_path = os.path.join(self.tmp_dir, 'config.yml')
     with io.open(tmp_file_path, 'w', encoding='utf-8') as f:
         f.write(u"""
             TestBeds:
                 # A test bed where adb will find Android devices.
                 - Name: SampleTestBed
                   Controllers:
                       MagicDevice: '*'
         """)
     test_runner.main(['-c', tmp_file_path])
     mock_exit.assert_called_once_with(1)
Exemplo n.º 2
0
 def test_main(self, mock_exit, mock_find_test):
     tmp_file_path = os.path.join(self.tmp_dir, 'config.yml')
     with io.open(tmp_file_path, 'w', encoding='utf-8') as f:
         f.write(u"""
             TestBeds:
                 # A test bed where adb will find Android devices.
                 - Name: SampleTestBed
                   Controllers:
                       MagicDevice: '*'
                   TestParams:
                       icecream: 42
                       extra_param: 'haha'
         """)
     test_runner.main(['-c', tmp_file_path])
     mock_exit.assert_not_called()
Exemplo n.º 3
0
    def RunMoblyModule(self):
        '''Execute mobly test module.'''
        # Because mobly and vts uses a similar runner, both will modify
        # log_path from python logging. The following step is to preserve
        # log path after mobly test finishes.

        # An alternative way is to start a new python process through shell
        # command. In that case, test print out needs to be piped.
        # This will also help avoid log overlapping

        logger = logging.getLogger()
        logger_path = logger.log_path
        logging_path = logging.log_path

        try:
            mobly_test_runner.main(argv=['-c', self.mobly_config_file_path])
        finally:
            logger.log_path = logger_path
            logging.log_path = logging_path
Exemplo n.º 4
0
 def test_main_parse_args(self, mock_test_runner, mock_config,
                          mock_find_test):
     test_runner.main(['-c', 'some/path/foo.yaml', '-b', 'hello'])
     mock_config.assert_called_with('some/path/foo.yaml', None)
# limitations under the License.

from chip_mobly import pigweed_device
from mobly import asserts  # type: ignore
from mobly import base_test
from mobly import test_runner


class HelloWorldTest(base_test.BaseTestClass):
    def setup_class(self):
        # Registering pigweed_device controller module declares the test's
        # dependency on CHIP/Pigweed device hardware. By default, we expect at least one
        # object is created from this.
        # Assumes correct image is already flashed.
        self.ads = self.register_controller(pigweed_device)
        self.dut = self.ads[0]

    def test_hello(self):
        expected = "hello!"
        status, payload = self.dut.rpcs().EchoService.Echo(msg=expected)
        asserts.assert_true(status.ok(), "Status is %s" % status)
        asserts.assert_equal(
            payload.msg,
            expected,
            'Returned payload is "%s" expected "%s"' % (payload.msg, expected),
        )


if __name__ == "__main__":
    test_runner.main()
Exemplo n.º 6
0
def main():
    """Runs the current test suite."""
    test_runner.main()