_testing.py 1007 B

123456789101112131415161718192021222324252627282930313233343536
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright 2022 Google LLC
  3. #
  4. """Bintool used for testing
  5. This is not a real bintool, just one used for testing"""
  6. from binman import bintool
  7. # pylint: disable=C0103
  8. class Bintool_testing(bintool.Bintool):
  9. """Bintool used for testing"""
  10. def __init__(self, name):
  11. super().__init__(name, 'testing')
  12. self.present = False
  13. self.install = False
  14. self.disable = False
  15. def is_present(self):
  16. if self.present is None:
  17. return super().is_present()
  18. return self.present
  19. def version(self):
  20. return '123'
  21. def fetch(self, method):
  22. if self.disable:
  23. return super().fetch(method)
  24. if method == bintool.FETCH_BIN:
  25. if self.install:
  26. return self.apt_install('package')
  27. return self.fetch_from_drive('junk')
  28. if method == bintool.FETCH_BUILD:
  29. return self.build_from_git('url', 'target', 'pathname')
  30. return None