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