hello_world_test.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (c) 2020 Project CHIP Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from chip_mobly import pigweed_device
  15. from mobly import asserts # type: ignore
  16. from mobly import base_test, test_runner
  17. class HelloWorldTest(base_test.BaseTestClass):
  18. def setup_class(self):
  19. # Registering pigweed_device controller module declares the test's
  20. # dependency on CHIP/Pigweed device hardware. By default, we expect at least one
  21. # object is created from this.
  22. # Assumes correct image is already flashed.
  23. self.ads = self.register_controller(pigweed_device)
  24. self.dut = self.ads[0]
  25. def test_hello(self):
  26. expected = "hello!"
  27. status, payload = self.dut.rpcs().EchoService.Echo(msg=expected)
  28. asserts.assert_true(status.ok(), "Status is %s" % status)
  29. asserts.assert_equal(
  30. payload.msg,
  31. expected,
  32. 'Returned payload is "%s" expected "%s"' % (payload.msg, expected),
  33. )
  34. if __name__ == "__main__":
  35. test_runner.main()