blob: 89935bc787b82ac8e0fa3a8b8cfbeb4f604fe5ad [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Matteo Scandolo67654fa2017-06-09 09:33:17 -070017import unittest
18import os
19from mock import patch
20from xosgenx.xosgen import XosGen
21
22class Args:
23 pass
24
25class XOSGeneratorTest(unittest.TestCase):
26 """
27 Testing the CLI binding for the XOS Generative Toolchain
28 """
29
30 def test_generator(self):
31 """
32 [XOS-GenX] The CLI entry point should correctly parse params
33 """
34 args = Args()
35 args.files = ['tests/xproto/test.xproto']
36 args.target = 'tests/xtarget/test.xtarget'
37 args.output = 'tests/out/dir/'
38 args.write_to_file = "target"
39 args.dest_file = None
40 args.dest_extension = None
41
42 expected_args = Args()
43 expected_args.files = [os.path.abspath(os.getcwd() + '/' + args.files[0])]
44 expected_args.target = os.path.abspath(os.getcwd() + '/' + args.target)
45 expected_args.output = os.path.abspath(os.getcwd() + '/' + args.output)
46
47 with patch("xosgenx.xosgen.XOSGenerator.generate") as generator:
48 XosGen.init(args)
49 actual_args = generator.call_args[0][0]
50 self.assertEqual(actual_args.files, expected_args.files)
51 self.assertEqual(actual_args.target, expected_args.target)
52 self.assertEqual(actual_args.output, expected_args.output)
53
54if __name__ == '__main__':
Sapan Bhatia5ea307d2017-07-19 00:13:21 -040055 unittest.main()