

def test_pagila(self):
    if (self.srcdb.version < 90000):
        self.srcdb.execute('CREATE PROCEDURAL LANGUAGE plpgsql')
        self.srcdb.execute_commit('ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres')
    self.execute_script(__file__, 'pagila-schema.sql')
    srcdump = self.tempfile_path('pagila-src.dump')
    self.run_pg_dump(srcdump, True)
    srcyaml = self.tempfile_path('pagila-src.yaml')
    self.create_yaml(srcyaml, True)
    emptydump = self.tempfile_path('empty.dump')
    self.run_pg_dump(emptydump)
    emptyyaml = self.tempfile_path('empty.yaml')
    self.create_yaml(emptyyaml)
    targsql = self.tempfile_path('pagila.sql')
    self.migrate_target(srcyaml, targsql)
    targdump = self.tempfile_path('pagila.dump')
    self.run_pg_dump(targdump)
    targyaml = self.tempfile_path('pagila.yaml')
    self.create_yaml(targyaml)
    adds = []
    subs = []
    for line in unified_diff(self.lines(srcdump), self.lines(targdump)):
        if ((line == '--- \n') or (line == '+++ \n') or line.startswith('@@')):
            continue
        if (line[:1] == '+'):
            adds.append(line[1:(- 1)])
        elif (line[:1] == '-'):
            subs.append(line[1:(- 1)])
    subs = sorted(subs)
    for (i, line) in enumerate(sorted(adds)):
        assert (line == subs[i])
    assert (self.lines(srcyaml) == self.lines(targyaml))
    self.migrate_target(emptyyaml, i)
    self.run_pg_dump(targdump)
    self.create_yaml(targyaml)
    assert (self.lines(emptydump) == self.lines(targdump))
    assert (self.lines(emptyyaml) == self.lines(targyaml))

dataset/ETHPy150Open perseas/Pyrseas/tests/functional/test_pagila.py PagilaTestCase.test_pagila/VarMisuse@345/498 `targsql`->`i`