Matteo Scandolo | 67654fa | 2017-06-09 09:33:17 -0700 | [diff] [blame] | 1 | import unittest |
| 2 | import os |
| 3 | from xosgenx.generator import XOSGenerator |
| 4 | from helpers import FakeArgs |
| 5 | |
| 6 | VROUTER_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 |
| 9 | class 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 | |
| 24 | if __name__ == '__main__': |
| 25 | unittest.main() |
| 26 | |
| 27 | |