blob: 6e76073685234dd1eca36f329ddb505d87416a91 [file] [log] [blame]
Matteo Scandolo67654fa2017-06-09 09:33:17 -07001import unittest
2import os
3from mock import patch
4from xosgenx.xosgen import XosGen
5
6class Args:
7 pass
8
9class 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
38if __name__ == '__main__':
Sapan Bhatia5ea307d2017-07-19 00:13:21 -040039 unittest.main()