@@ -59,25 +59,6 @@ def delete_tables(self):
5959 table_names .remove (tbl )
6060 connection .enable_constraint_checking ()
6161
62- def get_indexes (self , table ):
63- """
64- Get the indexes on the table using a new cursor.
65- """
66- with connection .cursor () as cursor :
67- return [
68- c ["columns" ][0 ]
69- for c in connection .introspection .get_constraints (cursor , table ).values ()
70- if c ["index" ] and len (c ["columns" ]) == 1
71- ]
72-
73- def get_uniques (self , table ):
74- with connection .cursor () as cursor :
75- return [
76- c ["columns" ][0 ]
77- for c in connection .introspection .get_constraints (cursor , table ).values ()
78- if c ["unique" ] and len (c ["columns" ]) == 1
79- ]
80-
8162 def get_constraints (self , table ):
8263 """
8364 Get the constraints on a table using a new cursor.
@@ -93,41 +74,6 @@ def get_constraints_for_columns(self, model, columns):
9374 constraints_for_column .append (name )
9475 return sorted (constraints_for_column )
9576
96- def check_added_field_default (
97- self ,
98- schema_editor ,
99- model ,
100- field ,
101- field_name ,
102- expected_default ,
103- cast_function = None ,
104- ):
105- schema_editor .add_field (model , field )
106- database_default = connection .database [model ._meta .db_table ].find_one ().get (field_name )
107- if cast_function and type (database_default ) is not type (expected_default ):
108- database_default = cast_function (database_default )
109- self .assertEqual (database_default , expected_default )
110-
111- def get_constraints_count (self , table , column , fk_to ):
112- """
113- Return a dict with keys 'fks', 'uniques, and 'indexes' indicating the
114- number of foreign keys, unique constraints, and indexes on
115- `table`.`column`. The `fk_to` argument is a 2-tuple specifying the
116- expected foreign key relationship's (table, column).
117- """
118- with connection .cursor () as cursor :
119- constraints = connection .introspection .get_constraints (cursor , table )
120- counts = {"fks" : 0 , "uniques" : 0 , "indexes" : 0 }
121- for c in constraints .values ():
122- if c ["columns" ] == [column ]:
123- if c ["foreign_key" ] == fk_to :
124- counts ["fks" ] += 1
125- if c ["unique" ]:
126- counts ["uniques" ] += 1
127- elif c ["index" ]:
128- counts ["indexes" ] += 1
129- return counts
130-
13177 def assertIndexOrder (self , table , index , order ):
13278 constraints = self .get_constraints (table )
13379 self .assertIn (index , constraints )
@@ -136,27 +82,6 @@ def assertIndexOrder(self, table, index, order):
13682 all (val == expected for val , expected in zip (index_orders , order , strict = True ))
13783 )
13884
139- def assertForeignKeyExists (self , model , column , expected_fk_table , field = "id" ):
140- """
141- Fail if the FK constraint on `model.Meta.db_table`.`column` to
142- `expected_fk_table`.id doesn't exist.
143- """
144- if not connection .features .can_introspect_foreign_keys :
145- return
146- constraints = self .get_constraints (model ._meta .db_table )
147- constraint_fk = None
148- for details in constraints .values ():
149- if details ["columns" ] == [column ] and details ["foreign_key" ]:
150- constraint_fk = details ["foreign_key" ]
151- break
152- self .assertEqual (constraint_fk , (expected_fk_table , field ))
153-
154- def assertForeignKeyNotExists (self , model , column , expected_fk_table ):
155- if not connection .features .can_introspect_foreign_keys :
156- return
157- with self .assertRaises (AssertionError ):
158- self .assertForeignKeyExists (model , column , expected_fk_table )
159-
16085 def assertTableExists (self , model ):
16186 self .assertIn (model ._meta .db_table , connection .introspection .table_names ())
16287
0 commit comments