report.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #
  2. # All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. # its licensors.
  4. #
  5. # For complete copyright and license terms please see the LICENSE at the root of this
  6. # distribution (the "License"). All use of this software is governed by the License,
  7. # or, if provided, by the license below or the license accompanying this file. Do not
  8. # remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. #
  11. # These methods are useful for testing purposes as they output different patterns of
  12. # lines that would appear in the console or various log files. These lines can then be
  13. # picked up via console/log monitoring or log parsing for automated/manual testing
  14. import azlmbr.legacy.general as general
  15. class Report:
  16. @staticmethod
  17. def info(msg: str) -> None:
  18. print(f"Info: {msg}")
  19. @staticmethod
  20. def success(success_message: str) -> None:
  21. print(f"Success: {success_message}")
  22. @staticmethod
  23. def failure() -> None:
  24. print("Failure: A pass condition has not passed in this test")
  25. @staticmethod
  26. def result(success_message: str, condition: bool) -> None:
  27. """
  28. This would be used for expecting a True output on some condition
  29. Example:
  30. level_loaded = EditorTestHelper.open_level("Example")
  31. Report.result("Example level loaded successfully", level_loaded)
  32. """
  33. if not isinstance(condition, bool):
  34. raise TypeError("condition argument must be a bool")
  35. if condition:
  36. Report.success(success_message)
  37. else:
  38. Report.failure()
  39. return condition