Exemplo n.º 1
0
def test_dumpcmd():
    assert dumpcmd(None, "/tmp") == ([
        "sqlite3", os.path.join("/tmp", "db", "cuckoo.db"), ".dump"
    ], {})
    assert dumpcmd("sqlite:///db/cuckoo.db", "/tmp") == ([
        "sqlite3", os.path.join("/tmp", "db/cuckoo.db"), ".dump"
    ], {})
    assert dumpcmd("sqlite:////tmp/cuckoo.db",
                   "/tmp") == (["sqlite3", "/tmp/cuckoo.db", ".dump"], {})
    assert dumpcmd("mysql://*****:*****@localh0st/baz", "/tmp") == ([
        "mysqldump", "-u", "foo", "-pbar", "-h", "localh0st", "baz"
    ], {})
    assert dumpcmd("postgresql://*****:*****@localhost/baz",
                   "/tmp") == (["pg_dump", "-U", "user", "baz"], {
                       "PGPASSWORD": "******"
                   })
Exemplo n.º 2
0
def test_dumpcmd():
    assert dumpcmd(None, "/tmp") == (
        ["sqlite3", os.path.join("/tmp", "db/cuckoo.db"), ".dump"], {}
    )
    assert dumpcmd("sqlite:///db/cuckoo.db", "/tmp") == (
        ["sqlite3", os.path.join("/tmp", "db/cuckoo.db"), ".dump"], {}
    )
    assert dumpcmd("sqlite:////tmp/cuckoo.db", "/tmp") == (
        ["sqlite3", "/tmp/cuckoo.db", ".dump"], {}
    )
    assert dumpcmd("mysql://*****:*****@localh0st/baz", "/tmp") == (
        ["mysqldump", "-u", "foo", "-pbar", "-h", "localh0st", "baz"], {}
    )
    assert dumpcmd("mysql://*****:*****@localhost/cuckoo", "/tmp") == (
        ["mysqldump", "-u", "cuckoo", "-prandom!", "cuckoo"], {}
    )
    assert dumpcmd("postgresql://*****:*****@localhost/baz", "/tmp") == (
        ["pg_dump", "-U", "user", "baz"], {"PGPASSWORD": "******"}
    )
    assert dumpcmd("postgresql://user name!:bar@localhost/baz", "/tmp") == (
        ["pg_dump", "-U", "user name!", "baz"], {"PGPASSWORD": "******"}
    )
    assert dumpcmd("postgresql://:b@c/d", "/tmp") == (
        ["pg_dump", "-h", "c", "d"], {"PGPASSWORD": "******"}
    )

    with pytest.raises(CuckooOperationalError) as e:
        dumpcmd("notadatabaseuri", "/tmp")
    e.match("URI wasn't understood")

    with pytest.raises(CuckooOperationalError) as e:
        dumpcmd("notadatabase://*****:*****@c/d", "/tmp")
    e.match("URI wasn't understood")
Exemplo n.º 3
0
def test_dumpcmd():
    assert dumpcmd(None, "/tmp") == ([
        "sqlite3", os.path.join("/tmp", "db/cuckoo.db"), ".dump"
    ], {})
    assert dumpcmd("sqlite:///db/cuckoo.db", "/tmp") == ([
        "sqlite3", os.path.join("/tmp", "db/cuckoo.db"), ".dump"
    ], {})
    assert dumpcmd("sqlite:////tmp/cuckoo.db",
                   "/tmp") == (["sqlite3", "/tmp/cuckoo.db", ".dump"], {})
    assert dumpcmd("mysql://*****:*****@localh0st/baz", "/tmp") == ([
        "mysqldump", "-u", "foo", "-pbar", "-h", "localh0st", "baz"
    ], {})
    assert dumpcmd("mysql://*****:*****@localhost/cuckoo", "/tmp") == ([
        "mysqldump", "-u", "cuckoo", "-prandom!", "cuckoo"
    ], {})
    assert dumpcmd("postgresql://*****:*****@localhost/baz",
                   "/tmp") == (["pg_dump", "-U", "user", "baz"], {
                       "PGPASSWORD": "******"
                   })
    assert dumpcmd("postgresql://user name!:bar@localhost/baz",
                   "/tmp") == (["pg_dump", "-U", "user name!", "baz"], {
                       "PGPASSWORD": "******"
                   })
    assert dumpcmd("postgresql://:b@c/d",
                   "/tmp") == (["pg_dump", "-h", "c", "d"], {
                       "PGPASSWORD": "******"
                   })

    with pytest.raises(CuckooOperationalError) as e:
        dumpcmd("notadatabaseuri", "/tmp")
    e.match("URI wasn't understood")

    with pytest.raises(CuckooOperationalError) as e:
        dumpcmd("notadatabase://*****:*****@c/d", "/tmp")
    e.match("URI wasn't understood")