def test_wrong_pk(self): val = '[pk, name: "not allowed"]' with self.assertRaises(ParseSyntaxException): index_settings.parseString(val, parseAll=True) val2 = '[note: "pk not allowed", pk]' with self.assertRaises(ParseSyntaxException): index_settings.parseString(val2, parseAll=True)
def test_all(self): val = '[type: hash, name: "index name", note: "index note", unique]' res = index_settings.parseString(val, parseAll=True) self.assertEqual(res[0]['type_'], 'hash') self.assertEqual(res[0]['name'], 'index name') self.assertEqual(res[0]['note'].text, 'index note') self.assertTrue(res[0]['unique'])
def test_name_type_multiline(self): val = '[\nname: "index name"\n,\ntype:\nbtree\n]' res = index_settings.parseString(val, parseAll=True) self.assertEqual(res[0]['type_'], 'btree') self.assertEqual(res[0]['name'], 'index name')
def test_pk(self): val = '[\npk\n]' res = index_settings.parseString(val, parseAll=True) self.assertTrue(res[0]['pk'])
def test_unique(self): val = '[unique]' res = index_settings.parseString(val, parseAll=True) self.assertTrue(res[0]['unique'])