Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 1 | import unittest |
| 2 | import os |
| 3 | from mock import patch |
| 4 | from xosgenx.xosgen import XosGen |
| 5 | |
| 6 | class Args: |
| 7 | pass |
| 8 | |
| 9 | class XOSGeneratorTest(unittest.TestCase): |
| 10 | """ |
| 11 | Testing the CLI binding for the XOS Generative Toolchain |
| 12 | """ |
| 13 | |
| 14 | def test_generator(self): |
| 15 | """ |
| 16 | [XOS-GenX] The CLI entry point should correctly parse params |
| 17 | """ |
| 18 | args = Args() |
| 19 | args.files = ['tests/xproto/test.xproto'] |
| 20 | args.target = 'tests/xtarget/test.xtarget' |
| 21 | args.output = 'tests/out/dir/' |
| 22 | args.write_to_file = "target" |
| 23 | args.dest_file = None |
| 24 | args.dest_extension = None |
| 25 | |
| 26 | expected_args = Args() |
| 27 | expected_args.files = [os.path.abspath(os.getcwd() + '/' + args.files[0])] |
| 28 | expected_args.target = os.path.abspath(os.getcwd() + '/' + args.target) |
| 29 | expected_args.output = os.path.abspath(os.getcwd() + '/' + args.output) |
| 30 | |
| 31 | with patch("xosgenx.xosgen.XOSGenerator.generate") as generator: |
| 32 | XosGen.init(args) |
| 33 | actual_args = generator.call_args[0][0] |
| 34 | self.assertEqual(actual_args.files, expected_args.files) |
| 35 | self.assertEqual(actual_args.target, expected_args.target) |
| 36 | self.assertEqual(actual_args.output, expected_args.output) |
| 37 | |
| 38 | if __name__ == '__main__': |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 39 | unittest.main() |