示例#1
0
def test_query_instapaper(tdir):
    index_hypothesis(tdir)
    test_url = "http://www.e-flux.com/journal/53/59883/the-black-stack/"
    with wserver(db=tdir / 'promnesia.sqlite') as helper:
        response = post(f'http://localhost:{helper.port}/visits',
                        f'url={test_url}')
        assert len(response['visits']) > 5
示例#2
0
def test_search(tdir):
    index_hypothesis(tdir)
    test_url = "http://www.e-flux.com"
    with wserver(db=tdir / 'promnesia.sqlite') as helper:
        response = post(f'http://localhost:{helper.port}/search',
                        f'url={test_url}')
        assert len(response['visits']) == 8
示例#3
0
def test_search_around(tmp_path):
    tdir = Path(tmp_path)
    index_hypothesis(tdir)
    dt = pytz.utc.localize(datetime.strptime("2017-05-22T10:58:14.082375", '%Y-%m-%dT%H:%M:%S.%f'))
    test_ts = int(dt.timestamp())
    # test_ts = int(datetime(2016, 12, 13, 12, 31, 4, 229275, tzinfo=pytz.utc).timestamp())
    # TODO hmm. perhaps it makes more sense to run query in different process and server in main process for testing??
    with wserver(db=tdir / 'promnesia.sqlite') as helper:
        response = post(f'http://localhost:{helper.port}/search_around', f'timestamp={test_ts}')
        # TODO highlight original url in extension??
        assert 5 < len(response['visits']) < 20
示例#4
0
def test_search_around(tmp_path) -> None:
    tdir = Path(tmp_path)
    index_hypothesis(tdir)
    index_extra(tdir)

    dt = pytz.utc.localize(
        datetime.strptime("2017-05-22T10:58:14.082375",
                          '%Y-%m-%dT%H:%M:%S.%f'))

    dt2 = pytz.timezone('America/New_York').localize(
        datetime.strptime("2018-06-01T10:00:00.00000", '%Y-%m-%dT%H:%M:%S.%f'))

    # TODO hmm. perhaps it makes more sense to run query in different process and server in main process for testing??
    with wserver(db=tdir / 'promnesia.sqlite') as helper:
        response = post(f'http://localhost:{helper.port}/search_around',
                        f'timestamp={int(dt.timestamp())}')
        # TODO highlight original url in extension??
        # should be exact??
        assert 5 < len(response['visits']) < 20, response

        response = post(f'http://localhost:{helper.port}/search_around',
                        f'timestamp={int(dt2.timestamp())}')
        assert len(response['visits']) > 10, response