Exemplo n.º 1
0
 def test_pk(self) -> None:
     res = column_settings.parseString('[pk]', parseAll=True)
     self.assertTrue(res[0]['pk'])
     res = column_settings.parseString('[primary key]', parseAll=True)
     self.assertTrue(res[0]['pk'])
     res = column_settings.parseString('[primary key, pk]', parseAll=True)
     self.assertTrue(res[0]['pk'])
Exemplo n.º 2
0
 def test_refs(self):
     res = column_settings.parseString('[ref: > table.column]',
                                       parseAll=True)
     self.assertEqual(len(res[0]['ref_blueprints']), 1)
     res = column_settings.parseString(
         '[ref: - table.column, ref: < table2.column2]', parseAll=True)
     self.assertEqual(len(res[0]['ref_blueprints']), 2)
Exemplo n.º 3
0
 def test_nulls(self) -> None:
     res = column_settings.parseString('[NULL]', parseAll=True)
     self.assertNotIn('not_null', res[0])
     res = column_settings.parseString('[NOT NULL]', parseAll=True)
     self.assertTrue(res[0]['not_null'])
     res = column_settings.parseString('[NULL, NOT NULL]', parseAll=True)
     self.assertTrue(res[0]['not_null'])
     res = column_settings.parseString('[NOT NULL, NULL]', parseAll=True)
     self.assertNotIn('not_null', res[0])
Exemplo n.º 4
0
 def test_wrong(self) -> None:
     val = "[wrong]"
     with self.assertRaises(ParseSyntaxException):
         column_settings.parseString(val, parseAll=True)
Exemplo n.º 5
0
 def test_note_default(self) -> None:
     res = column_settings.parseString('[default: 123, note: "mynote"]', parseAll=True)
     self.assertIn('note', res[0])
     self.assertEqual(res[0]['default'], 123)
Exemplo n.º 6
0
 def test_unique_increment(self) -> None:
     res = column_settings.parseString('[unique, increment]', parseAll=True)
     self.assertTrue(res[0]['unique'])
     self.assertTrue(res[0]['autoinc'])