Example #1
0
def test_it_normalizes_document_meta_claimant(req):
    docmeta_1 = models.DocumentMeta(_claimant='http://example.org/',
                                    _claimant_normalized='http://example.org',
                                    type='title',
                                    value=['Test Title'])
    docmeta_2 = models.DocumentMeta(_claimant='http://example.net/',
                                    _claimant_normalized='http://example.net',
                                    type='title',
                                    value=['Test Title'])

    req.db.add(models.Document(meta=[docmeta_1, docmeta_2]))
    req.db.flush()

    normalize_uris.normalize_document_meta(req)

    assert docmeta_1.claimant_normalized == 'httpx://example.org'
    assert docmeta_2.claimant_normalized == 'httpx://example.net'
Example #2
0
def test_it_deletes_duplicate_document_meta_objects(req):
    docmeta_1 = models.DocumentMeta(
        _claimant="http://example.org/", type="title", value=["Test Title"]
    )
    docmeta_1._claimant_normalized = "http://example.org"
    docmeta_2 = models.DocumentMeta(
        _claimant="https://example.org/", type="title", value=["Test Title"]
    )
    docmeta_2._claimant_normalized = "https://example.org"

    req.db.add_all(
        [models.Document(meta=[docmeta_1]), models.Document(meta=[docmeta_2])]
    )
    req.db.flush()

    normalize_uris.normalize_document_meta(req)

    assert req.db.query(models.DocumentMeta).count() == 1
Example #3
0
def test_it_deletes_duplicate_document_meta_objects(req):
    docmeta_1 = models.DocumentMeta(_claimant="http://example.org/",
                                    type="title",
                                    value=["Test Title"])
    docmeta_1._claimant_normalized = "http://example.org"
    docmeta_2 = models.DocumentMeta(_claimant="https://example.org/",
                                    type="title",
                                    value=["Test Title"])
    docmeta_2._claimant_normalized = "https://example.org"

    req.db.add_all(
        [models.Document(meta=[docmeta_1]),
         models.Document(meta=[docmeta_2])])
    req.db.flush()

    normalize_uris.normalize_document_meta(req)

    assert req.db.query(models.DocumentMeta).count() == 1
Example #4
0
def test_it_normalizes_document_meta_claimant(req):
    docmeta_1 = models.DocumentMeta(
        _claimant="http://example.org/",
        _claimant_normalized="http://example.org",
        type="title",
        value=["Test Title"],
    )
    docmeta_2 = models.DocumentMeta(
        _claimant="http://example.net/",
        _claimant_normalized="http://example.net",
        type="title",
        value=["Test Title"],
    )

    req.db.add(models.Document(meta=[docmeta_1, docmeta_2]))
    req.db.flush()

    normalize_uris.normalize_document_meta(req)

    assert docmeta_1.claimant_normalized == "httpx://example.org"
    assert docmeta_2.claimant_normalized == "httpx://example.net"
Example #5
0
def test_it_normalizes_document_meta_claimant(req):
    docmeta_1 = models.DocumentMeta(
        _claimant="http://example.org/",
        _claimant_normalized="http://example.org",
        type="title",
        value=["Test Title"],
    )
    docmeta_2 = models.DocumentMeta(
        _claimant="http://example.net/",
        _claimant_normalized="http://example.net",
        type="title",
        value=["Test Title"],
    )

    req.db.add(models.Document(meta=[docmeta_1, docmeta_2]))
    req.db.flush()

    normalize_uris.normalize_document_meta(req)

    assert docmeta_1.claimant_normalized == "httpx://example.org"
    assert docmeta_2.claimant_normalized == "httpx://example.net"