blob: 08997b70b78132a02ca1098c3304fb53f8373543 [file] [log] [blame]
Matteo Scandolo67654fa2017-06-09 09:33:17 -07001import unittest
2import os
3from xosgenx.generator import XOSGenerator
4from helpers import FakeArgs
5
6VROUTER_XPROTO = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xproto/vrouterport.xproto")
7
8# Generate Protobuf from Xproto and then parse the resulting Protobuf
9class XProtoProtobufGeneratorTest(unittest.TestCase):
10 def test_proto_generator(self):
11 """
12 [XOS-GenX] Generate DJANGO models, verify Fields and Foreign Keys
13 """
14 args = FakeArgs()
15 args.files = [VROUTER_XPROTO]
16 args.target = 'django.xtarget'
17 output = XOSGenerator.generate(args)
18
19 fields = filter(lambda s:'Field(' in s, output.splitlines())
20 self.assertEqual(len(fields), 2)
21 links = filter(lambda s:'Key(' in s, output.splitlines())
22 self.assertEqual(len(links), 2)
23
24if __name__ == '__main__':
25 unittest.main()
26
27