def test_create_with_foreign_key(self):
        "Create a table with a foreign key constraint"
        inmap = self.std_map()
        inmap['schema public'].update(
            {'table t1': {'columns': [{'c11': {'type': 'integer'}},
                                      {'c12': {'type': 'text'}}]},
             'table t2': {'columns': [{'c21': {'type': 'integer'}},
                                      {'c22': {'type': 'text'}},
                                      {'c23': {'type': 'integer'}}],
                          'foreign_keys': {'t2_c23_fkey': {
                              'columns': ['c23'],
                              'references': {'columns': ['c11'],
                                             'table': 't1'}}}}})
        sql = self.to_sql(inmap)
        # can't control which table will be created first
        crt1 = 0
        crt2 = 1
        if sql[1] in 't1':
            crt1 = 1
            crt2 = 0
        assert fix_indent(sql[crt1]) == \
            "CREATE TABLE t1 (c11 integer, c12 text)"
        assert fix_indent(sql[crt2]) == \
            "CREATE TABLE t2 (c21 integer, c22 text, c23 integer)"
        assert fix_indent(sql[2]) == "ALTER TABLE t2 ADD CONSTRAINT " \
            "t2_c23_fkey FOREIGN KEY (c23) REFERENCES t1 (c11)"
dataset/ETHPy150Open perseas/Pyrseas/tests/dbobject/test_constraint.py/ForeignKeyToSqlTestCase.test_create_with_foreign_key/swapped operands of `in`