def test_rowcounts_works(test_db_env, capsys):
    subprocess.check_call(['python', 'load_dataset.py', 'hpd_registrations'],
                          env=test_db_env)
    capsys.readouterr()

    dbtool.main(['rowcounts', 'hpd_registrations'], DATABASE_URL)
    out, err = capsys.readouterr()

    assert "hpd_registrations has 100 rows" in out
    assert "hpd_contacts has 100 rows" in out
def test_reset_lastmod_works(db, capsys):
    url = HPD_REG_URL
    with load_dbhash() as dbhash:
        info = LastmodInfo(url,
                           etag='blah',
                           last_modified='Tue, 01 Jan 2019 20:56:28 UTC')
        info.write_to_dbhash(dbhash)

    dbtool.main(['lastmod:reset', 'hpd_registrations'], DATABASE_URL)

    with load_dbhash() as dbhash:
        info = LastmodInfo.read_from_dbhash(url, dbhash)
        assert info == LastmodInfo(url=url, etag=None, last_modified=None)
 def list_lastmod():
     dbtool.main(['lastmod:list', 'hpd_registrations'], DATABASE_URL)
     out, err = capsys.readouterr()
     return out
def test_shell_works():
    with patch('nycdb.cli.run_dbshell') as m:
        dbtool.main(['shell'], DATABASE_URL)
    m.assert_called_once()