MCPcopy Create free account
hub / github.com/Vanderhoof/PyDBML / test_index_definition

Method test_index_definition

test/test_docs.py:100–136  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

98 self.assertEqual(rating.default, 10)
99
100 def test_index_definition(self) -> None:
101 results = PyDBML.parse_file(TEST_DOCS_PATH / 'index_definition.dbml')
102 self.assertEqual(len(results.tables), 1)
103 self.assertEqual(results.tables[0].name, 'bookings')
104
105 table = results.tables[0]
106 self.assertEqual([c.name for c in table.columns], ['id', 'country', 'booking_date', 'created_at'])
107 self.assertEqual(len(table.indexes), 8)
108
109 ix = table.indexes
110 self.assertEqual(ix[0].subjects, [table['id'], table['country']])
111 self.assertEqual(ix[0].comment, 'composite primary key')
112 self.assertTrue(ix[0].pk)
113
114 self.assertEqual(ix[1].subjects, [table['created_at']])
115 self.assertEqual(ix[1].name, 'created_at_index')
116 self.assertEqual(ix[1].note.text, 'Date')
117
118 self.assertEqual(ix[2].subjects, [table['booking_date']])
119
120 self.assertEqual(ix[3].subjects, [table['country'], table['booking_date']])
121 self.assertTrue(ix[3].unique)
122
123 self.assertEqual(ix[4].subjects, [table['booking_date']])
124 self.assertEqual(ix[4].type, 'hash')
125
126 self.assertEqual(len(ix[5].subjects), 1)
127 self.assertIsInstance(ix[5].subjects[0], Expression)
128 self.assertEqual(ix[5].subjects[0].text, 'id*2')
129
130 self.assertEqual(len(ix[6].subjects), 2)
131 self.assertIsInstance(ix[6].subjects[0], Expression)
132 self.assertIsInstance(ix[6].subjects[1], Expression)
133 self.assertEqual(ix[6].subjects[0].text, 'id*3')
134 self.assertEqual(ix[6].subjects[1].text, 'getdate()')
135
136 self.assertEqual(ix[7].subjects, [Expression('id*3'), table['id']])
137
138 def test_relationships(self) -> None:
139 results = PyDBML.parse_file(TEST_DOCS_PATH / 'relationships_1.dbml')

Callers

nothing calls this directly

Calls 2

ExpressionClass · 0.90
parse_fileMethod · 0.80

Tested by

no test coverage detected