Ejemplo n.º 1
0
 def test_newline(self):
     val = 'ref\nname: table1.col1 > table2.col2'
     with self.assertRaises(ParseException):
         ref_short.parseString(val, parseAll=True)
     val2 = 'ref name: table1.col1\n> table2.col2'
     with self.assertRaises(ParseSyntaxException):
         ref_short.parseString(val2, parseAll=True)
Ejemplo n.º 2
0
 def test_no_name(self):
     val = 'ref: table1.col1 > table2.col2'
     res = ref_short.parseString(val, parseAll=True)
     self.assertEqual(res[0].type, '>')
     self.assertEqual(res[0].table1, 'table1')
     self.assertEqual(res[0].col1, 'col1')
     self.assertEqual(res[0].table2, 'table2')
     self.assertEqual(res[0].col2, 'col2')
Ejemplo n.º 3
0
 def test_composite_with_name(self) -> None:
     val = 'ref name: table1.(col1 ,  col2,col3) > table2.(col11 ,  col21,col31)'
     res = ref_short.parseString(val, parseAll=True)
     self.assertEqual(res[0].type, '>')
     self.assertEqual(res[0].table1, 'table1')
     self.assertEqual(res[0].col1, '(col1 ,  col2,col3)')
     self.assertEqual(res[0].table2, 'table2')
     self.assertEqual(res[0].col2, '(col11 ,  col21,col31)')
     self.assertEqual(res[0].name, 'name')
Ejemplo n.º 4
0
 def test_comment_above(self):
     val = '//comment above\nref name: table1.col1 > table2.col2'
     res = ref_short.parseString(val, parseAll=True)
     self.assertEqual(res[0].type, '>')
     self.assertEqual(res[0].table1, 'table1')
     self.assertEqual(res[0].col1, 'col1')
     self.assertEqual(res[0].table2, 'table2')
     self.assertEqual(res[0].col2, 'col2')
     self.assertEqual(res[0].name, 'name')
     self.assertEqual(res[0].comment, 'comment above')
Ejemplo n.º 5
0
 def test_with_settings(self):
     val = 'ref name: table1.col1 > table2.col2 [update: cascade, delete: restrict]'
     res = ref_short.parseString(val, parseAll=True)
     self.assertEqual(res[0].type, '>')
     self.assertEqual(res[0].table1, 'table1')
     self.assertEqual(res[0].col1, 'col1')
     self.assertEqual(res[0].table2, 'table2')
     self.assertEqual(res[0].col2, 'col2')
     self.assertEqual(res[0].name, 'name')
     self.assertEqual(res[0].on_update, 'cascade')
     self.assertEqual(res[0].on_delete, 'restrict')
Ejemplo n.º 6
0
 def test_comment_both(self):
     val = '//comment above\nref name: table1.col1 > table2.col2 //comment after'
     res = ref_short.parseString(val, parseAll=True)
     self.assertEqual(res[0].type, '>')
     self.assertEqual(res[0].table1, 'table1')
     self.assertEqual(res[0].col1, 'col1')
     self.assertEqual(res[0].table2, 'table2')
     self.assertEqual(res[0].col2, 'col2')
     self.assertEqual(res[0].name, 'name')
     self.assertEqual(res[0].comment, 'comment after')
     val2 = '//comment above\nref name: table1.col1 > table2.col2 [update: cascade, delete: restrict] //comment after'
     res2 = ref_short.parseString(val2, parseAll=True)
     self.assertEqual(res2[0].type, '>')
     self.assertEqual(res2[0].table1, 'table1')
     self.assertEqual(res2[0].col1, 'col1')
     self.assertEqual(res2[0].table2, 'table2')
     self.assertEqual(res2[0].col2, 'col2')
     self.assertEqual(res2[0].name, 'name')
     self.assertEqual(res2[0].on_update, 'cascade')
     self.assertEqual(res2[0].on_delete, 'restrict')
     self.assertEqual(res2[0].comment, 'comment after')