|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | import unittest
|
| 16 | +import os |
16 | 17 | from metadata import Metadata
|
17 | 18 | from metadata import MetadataReader
|
18 | 19 | from os import path
|
19 | 20 |
|
20 | 21 |
|
21 | 22 | class TestMetadataReader(unittest.TestCase):
|
| 23 | + test_file = "simple_run_args.txt" |
22 | 24 |
|
23 | 25 | def setUp(self):
|
24 | 26 |
|
25 | 27 | # build the reader object
|
26 | 28 | self.reader=MetadataReader(path.join(path.dirname(__file__),"env_test.yaml"))
|
27 |
| - |
| 29 | + with open(self.test_file, 'w', encoding='utf8') as test_file: |
| 30 | + test_file.writelines(["# test-runner-runs: run1","\n# test-runner-run/run1: app/all-clusters discriminator KVS storage-path commissioning-method discriminator passcode"]) |
| 31 | + |
28 | 32 |
|
29 | 33 | def test_parse_single_run(self):
|
30 |
| - |
31 |
| - expected_runs_metadata = {} |
32 |
| - path_under_test=path.join(path.dirname(__file__),"simple_run_args.txt") |
33 | 34 |
|
34 |
| - expected_runs_metadata[path_under_test] = Metadata(app="out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app", |
35 |
| - discriminator=1234, py_script_path=path_under_test, run="run1", passcode=20202021) |
| 35 | + expected_runs_metadata = [] |
| 36 | + path_under_test=path.join(path.dirname(__file__),self.test_file) |
36 | 37 |
|
37 |
| - |
38 |
| - for run in expected_runs_metadata: |
39 |
| - self.assertEqual(self.reader.parse_script(run)[0], expected_runs_metadata[run]) |
40 |
| - |
| 38 | + expected_runs_metadata.append(Metadata(app="out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app", |
| 39 | + discriminator=1234, py_script_path=path_under_test, run="run1", passcode=20202021)) |
| 40 | + |
| 41 | + self.assertEqual(self.reader.parse_script(path_under_test), expected_runs_metadata) |
| 42 | + |
| 43 | + def tearDown(self): |
| 44 | + if os.path.exists(self.test_file): |
| 45 | + os.remove(self.test_file) |
| 46 | + |
41 | 47 |
|
42 | 48 | if __name__=="__main__":
|
43 | 49 | unittest.main()
|
|
0 commit comments