def test_with_settings(self) -> None: val = 'table ids as ii [headercolor: #ccc, note: "headernote"] {\nid integer\n}' res = table.parseString(val, parseAll=True) self.assertEqual(res[0].name, 'ids') self.assertEqual(res[0].alias, 'ii') self.assertEqual(res[0].header_color, '#ccc') self.assertEqual(res[0].note.text, 'headernote') self.assertEqual(len(res[0].columns), 1)
def test_with_body_note(self): val = ''' table ids as ii [ headercolor: #ccc, note: "headernote"] { id integer note: "bodynote" }''' res = table.parseString(val, parseAll=True) self.assertEqual(res[0].name, 'ids') self.assertEqual(res[0].alias, 'ii') self.assertEqual(res[0].header_color, '#ccc') self.assertEqual(res[0].note.text, 'bodynote') self.assertEqual(len(res[0].columns), 1)
def test_with_indexes(self) -> None: val = ''' table ids as ii [ headercolor: #ccc, note: "headernote"] { id integer country varchar note: "bodynote" indexes { (id, country) [pk] // composite primary key } }''' res = table.parseString(val, parseAll=True) self.assertEqual(res[0].name, 'ids') self.assertEqual(res[0].alias, 'ii') self.assertEqual(res[0].header_color, '#ccc') self.assertEqual(res[0].note.text, 'bodynote') self.assertEqual(len(res[0].columns), 2) self.assertEqual(len(res[0].indexes), 1)
def test_with_alias(self) -> None: val = 'table ids as ii {\nid integer\n}' res = table.parseString(val, parseAll=True) self.assertEqual(res[0].name, 'ids') self.assertEqual(res[0].alias, 'ii') self.assertEqual(len(res[0].columns), 1)
def test_simple(self) -> None: val = 'table ids {\nid integer\n}' res = table.parseString(val, parseAll=True) self.assertEqual(res[0].name, 'ids') self.assertEqual(len(res[0].columns), 1)