Ejemplo n.º 1
0
def test_it_normalizes_annotation_target_uri(req, factories, db_session):
    annotation_1 = factories.Annotation(userid='luke', target_uri='http://example.org/')
    annotation_1._target_uri_normalized = 'http://example.org'
    annotation_2 = factories.Annotation(userid='luke', target_uri='http://example.net/')
    annotation_2._target_uri_normalized = 'http://example.net'
    db_session.flush()

    normalize_uris.normalize_annotations(req)

    assert annotation_1.target_uri_normalized == 'httpx://example.org'
    assert annotation_2.target_uri_normalized == 'httpx://example.net'
Ejemplo n.º 2
0
def test_it_normalizes_annotation_target_uri(req, factories, db_session):
    annotation_1 = factories.Annotation(userid="luke", target_uri="http://example.org/")
    annotation_1._target_uri_normalized = "http://example.org"
    annotation_2 = factories.Annotation(userid="luke", target_uri="http://example.net/")
    annotation_2._target_uri_normalized = "http://example.net"
    db_session.flush()

    normalize_uris.normalize_annotations(req)

    assert annotation_1.target_uri_normalized == "httpx://example.org"
    assert annotation_2.target_uri_normalized == "httpx://example.net"
Ejemplo n.º 3
0
def test_it_skips_reindexing_unaltered_annotations(req, index, factories, db_session):
    factories.Annotation(userid="luke", target_uri="http://example.org/")
    annotation_2 = factories.Annotation(userid="luke", target_uri="http://example.net/")
    annotation_2._target_uri_normalized = "http://example.net"
    db_session.flush()

    indexer = index.BatchIndexer.return_value
    indexer.index.return_value = None

    normalize_uris.normalize_annotations(req)

    indexer.index.assert_called_once_with(set([annotation_2.id]))
Ejemplo n.º 4
0
def test_it_normalizes_annotation_target_uri(req, factories, db_session):
    annotation_1 = factories.Annotation(userid="luke",
                                        target_uri="http://example.org/")
    annotation_1._target_uri_normalized = "http://example.org"
    annotation_2 = factories.Annotation(userid="luke",
                                        target_uri="http://example.net/")
    annotation_2._target_uri_normalized = "http://example.net"
    db_session.flush()

    normalize_uris.normalize_annotations(req)

    assert annotation_1.target_uri_normalized == "httpx://example.org"
    assert annotation_2.target_uri_normalized == "httpx://example.net"
Ejemplo n.º 5
0
def test_it_skips_reindexing_unaltered_annotations(req, index, factories, db_session):
    factories.Annotation(userid='luke', target_uri='http://example.org/')
    annotation_2 = factories.Annotation(userid='luke',
                                        target_uri='http://example.net/')
    annotation_2._target_uri_normalized = 'http://example.net'
    db_session.flush()

    indexer = index.BatchIndexer.return_value
    indexer.index.return_value = None

    normalize_uris.normalize_annotations(req)

    indexer.index.assert_called_once_with(set([annotation_2.id]))
Ejemplo n.º 6
0
def test_it_reindexes_changed_annotations(req, index, factories, db_session):
    annotation_1 = factories.Annotation(userid='luke',
                                        target_uri='http://example.org/')
    annotation_1._target_uri_normalized = 'http://example.org'
    annotation_2 = factories.Annotation(userid='luke',
                                        target_uri='http://example.net/')
    annotation_2._target_uri_normalized='http://example.net'
    db_session.flush()

    indexer = index.BatchIndexer.return_value
    indexer.index.return_value = None

    normalize_uris.normalize_annotations(req)

    indexer.index.assert_called_once_with(set([annotation_1.id, annotation_2.id]))
Ejemplo n.º 7
0
def test_it_normalizes_annotation_target_uri(req):
    annotation_1 = models.Annotation(userid='luke',
                                     _target_uri='http://example.org/',
                                     _target_uri_normalized='http://example.org')
    annotation_2 = models.Annotation(userid='luke',
                                     _target_uri='http://example.net/',
                                     _target_uri_normalized='http://example.net')

    req.db.add_all([annotation_1, annotation_2])
    req.db.flush()

    normalize_uris.normalize_annotations(req)

    assert annotation_1.target_uri_normalized == 'httpx://example.org'
    assert annotation_2.target_uri_normalized == 'httpx://example.net'
def test_it_reindexes_changed_annotations(req, index, factories, db_session):
    annotation_1 = factories.Annotation(userid="luke",
                                        target_uri="http://example.org/")
    annotation_1._target_uri_normalized = "http://example.org"
    annotation_2 = factories.Annotation(userid="luke",
                                        target_uri="http://example.net/")
    annotation_2._target_uri_normalized = "http://example.net"
    db_session.flush()

    indexer = index.BatchIndexer.return_value
    indexer.index.return_value = None

    normalize_uris.normalize_annotations(req)

    indexer.index.assert_called_once_with({annotation_1.id, annotation_2.id})
Ejemplo n.º 9
0
def test_it_skips_reindexing_unaltered_annotations(req, index):
    annotation_1 = models.Annotation(userid='luke',
                                     target_uri='http://example.org/')
    annotation_2 = models.Annotation(userid='luke',
                                     _target_uri='http://example.net/',
                                     _target_uri_normalized='http://example.net')

    req.db.add_all([annotation_1, annotation_2])
    req.db.flush()

    indexer = index.BatchIndexer.return_value
    indexer.index.return_value = None

    normalize_uris.normalize_annotations(req)

    indexer.index.assert_called_once_with(set([annotation_2.id]))
Ejemplo n.º 10
0
def test_it_skips_reindexing_unaltered_annotations(req, index):
    annotation_1 = models.Annotation(userid='luke',
                                     target_uri='http://example.org/')
    annotation_2 = models.Annotation(
        userid='luke',
        _target_uri='http://example.net/',
        _target_uri_normalized='http://example.net')

    req.db.add_all([annotation_1, annotation_2])
    req.db.flush()

    indexer = index.BatchIndexer.return_value
    indexer.index.return_value = None

    normalize_uris.normalize_annotations(req)

    indexer.index.assert_called_once_with(set([annotation_2.id]))
Ejemplo n.º 11
0
def test_it_normalizes_annotation_target_uri(req):
    annotation_1 = models.Annotation(
        userid='luke',
        _target_uri='http://example.org/',
        _target_uri_normalized='http://example.org')
    annotation_2 = models.Annotation(
        userid='luke',
        _target_uri='http://example.net/',
        _target_uri_normalized='http://example.net')

    req.db.add_all([annotation_1, annotation_2])
    req.db.flush()

    normalize_uris.normalize_annotations(req)

    assert annotation_1.target_uri_normalized == 'httpx://example.org'
    assert annotation_2.target_uri_normalized == 'httpx://example.net'