test_data.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python3
  2. # Copyright (C) 2016 Intel Corporation
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. import unittest
  7. import logging
  8. import os
  9. from common import setup_sys_path, TestBase
  10. setup_sys_path()
  11. from oeqa.core.exception import OEQAMissingVariable
  12. from oeqa.core.utils.test import getCaseMethod, getSuiteCasesNames
  13. class TestData(TestBase):
  14. modules = ['data']
  15. def test_data_fail_missing_variable(self):
  16. expectedException = "oeqa.core.exception.OEQAMissingVariable"
  17. tc = self._testLoader(modules=self.modules)
  18. self.assertEqual(False, tc.runTests().wasSuccessful())
  19. for test, data in tc.errors:
  20. expect = False
  21. if expectedException in data:
  22. expect = True
  23. self.assertTrue(expect)
  24. def test_data_fail_wrong_variable(self):
  25. expectedError = 'AssertionError'
  26. d = {'IMAGE' : 'core-image-sato', 'ARCH' : 'arm'}
  27. tc = self._testLoader(d=d, modules=self.modules)
  28. self.assertEqual(False, tc.runTests().wasSuccessful())
  29. for test, data in tc.failures:
  30. expect = False
  31. if expectedError in data:
  32. expect = True
  33. self.assertTrue(expect)
  34. def test_data_ok(self):
  35. d = {'IMAGE' : 'core-image-minimal', 'ARCH' : 'x86', 'MACHINE' : 'qemuarm'}
  36. tc = self._testLoader(d=d, modules=self.modules)
  37. self.assertEqual(True, tc.runTests().wasSuccessful())
  38. if __name__ == '__main__':
  39. unittest.main()