(self, metadata, copy_fixture, copy_tables_fixture)
| 990 | |
| 991 | @testing.requires.check_constraints |
| 992 | def test_copy(self, metadata, copy_fixture, copy_tables_fixture): |
| 993 | |
| 994 | table, table2, table3 = copy_fixture |
| 995 | table_c, table2_c, table3_c, (has_constraints, reflect) = ( |
| 996 | copy_tables_fixture |
| 997 | ) |
| 998 | |
| 999 | self.assert_tables_equal(table, table_c) |
| 1000 | self.assert_tables_equal(table2, table2_c) |
| 1001 | assert table is not table_c |
| 1002 | assert table.primary_key is not table_c.primary_key |
| 1003 | assert list(table2_c.c.myid.foreign_keys)[0].column is table_c.c.myid |
| 1004 | assert list(table2_c.c.myid.foreign_keys)[0].column is not table.c.myid |
| 1005 | assert "x" in str(table_c.c.foo.server_default.arg) |
| 1006 | if not reflect: |
| 1007 | assert isinstance(table_c.c.myid.default, Sequence) |
| 1008 | assert str(table_c.c.foo.server_onupdate.arg) == "q" |
| 1009 | assert str(table_c.c.bar.default.arg) == "y" |
| 1010 | assert ( |
| 1011 | getattr( |
| 1012 | table_c.c.bar.onupdate.arg, |
| 1013 | "arg", |
| 1014 | table_c.c.bar.onupdate.arg, |
| 1015 | ) |
| 1016 | == "z" |
| 1017 | ) |
| 1018 | assert isinstance(table2_c.c.id.default, Sequence) |
| 1019 | |
| 1020 | if testing.requires.unique_constraint_reflection.enabled: |
| 1021 | for c in table_c.constraints: |
| 1022 | if isinstance(c, UniqueConstraint): |
| 1023 | break |
| 1024 | else: |
| 1025 | for c in table_c.indexes: |
| 1026 | break |
| 1027 | else: |
| 1028 | assert False |
| 1029 | |
| 1030 | assert c.columns.contains_column(table_c.c.name) |
| 1031 | assert not c.columns.contains_column(table.c.name) |
| 1032 | |
| 1033 | # CHECK constraints don't get reflected for any dialect right |
| 1034 | # now |
| 1035 | |
| 1036 | if has_constraints: |
| 1037 | for c in table_c.c.description.constraints: |
| 1038 | if isinstance(c, CheckConstraint): |
| 1039 | break |
| 1040 | else: |
| 1041 | assert False |
| 1042 | assert str(c.sqltext) == "description='hi'" |
| 1043 | |
| 1044 | if testing.requires.comment_reflection.enabled: |
| 1045 | eq_(table3_c.comment, "table comment") |
| 1046 | eq_(table3_c.c.foo.comment, "some column") |
| 1047 | |
| 1048 | def test_col_key_fk_parent(self): |
| 1049 | # test #2643 |
nothing calls this directly
no test coverage detected