示例#1
0
    def test_read_from_dbhash_works(self):
        dbh = DictDbHash({
            "etag:http://boop": "blah",
            "last_modified:http://boop": "flarg"
        })
        assert LastmodInfo.read_from_dbhash("http://boop", dbh) == LastmodInfo(
            url="http://boop", etag="blah", last_modified="flarg")

        assert LastmodInfo.read_from_dbhash("http://bar", dbh) == LastmodInfo(
            "http://bar", None, None)
示例#2
0
 def test_read_from_dbhash_works(self):
     dbh = DictDbHash({
         'etag:http://boop': 'blah',
         'last_modified:http://boop': 'flarg'
     })
     assert LastmodInfo.read_from_dbhash('http://boop', dbh) == LastmodInfo(
         url="http://boop", etag="blah", last_modified="flarg")
     
     assert LastmodInfo.read_from_dbhash('http://bar', dbh) == LastmodInfo(
         "http://bar", None, None)
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)
示例#4
0
def list_lastmod(db_url: str, dataset_names: List[str]):
    with psycopg2.connect(db_url) as conn:
        dbhash = load_dataset.get_dbhash(conn)
        for dataset in dataset_names:
            print(f"For the dataset {dataset}:")
            urls = load_dataset.get_urls_for_dataset(dataset)
            for url in urls:
                info = LastmodInfo.read_from_dbhash(url, dbhash)
                if info.last_modified:
                    print(
                        f"  The URL {url} was last modified on {info.last_modified}."
                    )
                else:
                    print(
                        f"  The URL {url} has no metadata about its last modification date."
                    )