Пример #1
0
def test_no_reference():
    blob = copy.deepcopy(TEST_BLOB)
    assert mf2util.classify_comment(blob, ('http://example.com', )) == []

    # add some irrelevant references
    blob['items'][1]['in-reply-to'] = [
        "http://werd.io/2014/homebrew-website-club-4",
        "https://www.facebook.com/events/1430990723825351/"
    ]
    assert mf2util.classify_comment(blob, ('http://example.com', )) == []

    # no target url
    assert mf2util.classify_comment(blob, ()) == []
Пример #2
0
def test_no_reference():
    blob = copy.deepcopy(TEST_BLOB)
    assert mf2util.classify_comment(blob, ('http://example.com',)) == []

    # add some irrelevant references
    blob['items'][1]['in-reply-to'] = [
        "http://werd.io/2014/homebrew-website-club-4",
        "https://www.facebook.com/events/1430990723825351/"
    ]
    assert mf2util.classify_comment(blob, ('http://example.com',)) == []

    # no target url
    assert mf2util.classify_comment(blob, ()) == []
Пример #3
0
def test_rsvps():
    blob = copy.deepcopy(TEST_BLOB)

    blob['items'][1]['properties'].update({
        'in-reply-to': ['http://mydomain.com/my-post'],
        'rsvp': ['yes'],
    })

    assert mf2util.classify_comment(
        blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')) \
        == ['rsvp', 'reply']
Пример #4
0
def test_rsvps():
    blob = copy.deepcopy(TEST_BLOB)

    blob['items'][1]['properties'].update({
        'in-reply-to': ['http://mydomain.com/my-post'],
        'rsvp': ['yes'],
    })

    assert mf2util.classify_comment(
        blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')) \
        == ['rsvp', 'reply']
Пример #5
0
def test_reposts():
    """make sure we find reposts"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'repost-of': ['http://mydomain.com/my-post'],
        'like-of': ['http://someoneelse.com/post'],
    })

    assert mf2util.classify_comment(
        blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')) \
        == ['repost']
Пример #6
0
def test_reposts():
    """make sure we find reposts"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'repost-of': ['http://mydomain.com/my-post'],
        'like-of': ['http://someoneelse.com/post'],
    })

    assert mf2util.classify_comment(
        blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')) \
        == ['repost']
Пример #7
0
def test_invites():
    blob = copy.deepcopy(TEST_BLOB)

    blob['items'][1]['properties'].update({
        'in-reply-to': ['http://mydomain.com/my-post'],
        'invitee': [{
            'name': 'Kyle Mahan',
            'url': 'https://kylewm.com',
        }],
    })

    assert mf2util.classify_comment(
        blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')) \
        == ['invite', 'reply']
Пример #8
0
def test_invites():
    blob = copy.deepcopy(TEST_BLOB)

    blob['items'][1]['properties'].update({
        'in-reply-to': ['http://mydomain.com/my-post'],
        'invitee': [{
            'name': 'Kyle Mahan',
            'url': 'https://kylewm.com',
        }],
    })

    assert mf2util.classify_comment(
        blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')) \
        == ['invite', 'reply']
Пример #9
0
def test_h_cite():
    """Test object references (e.g., class="p-in-reply-to h-cite")"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'in-reply-to': [{
            'type': 'h-cite',
            'properties': {
                'url': ['http://mydomain.com/my-post'],
            },
        }],
    })

    assert mf2util.classify_comment(blob, ('http://mydomain.com/my-post',))\
        == ['reply']
Пример #10
0
def test_multireply():
    """check behavior if our post is one among several posts
    in a multireply"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'in-reply-to': [
            'http://someoneelse.com/post',
            'http://mydomain.com/my-post',
            'http://athirddomain.org/permalink',
        ],
    })

    assert mf2util.classify_comment(blob, ('http://mydomain.com/my-post')) \
        == ['reply']
Пример #11
0
def test_h_cite():
    """Test object references (e.g., class="p-in-reply-to h-cite")"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'in-reply-to': [{
            'type': 'h-cite',
            'properties': {
                'url': ['http://mydomain.com/my-post'],
            },
        }],
    })

    assert mf2util.classify_comment(blob, ('http://mydomain.com/my-post',))\
        == ['reply']
Пример #12
0
def test_multireply():
    """check behavior if our post is one among several posts
    in a multireply"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'in-reply-to': [
            'http://someoneelse.com/post',
            'http://mydomain.com/my-post',
            'http://athirddomain.org/permalink',
        ],
    })

    assert mf2util.classify_comment(blob, ('http://mydomain.com/my-post')) \
        == ['reply']
Пример #13
0
def test_multimodal():
    """a mention can have more than one classification, make sure we find
    all of them. also tests some of the alternate/historical classnames"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'reply-to': ['http://noone.im/'],
        'repost-of': [
            'http://someoneelse.com',
            'http://mydomain.com/my-post',
        ],
        'like': [
            'http://mydoma.in/short',
            'http://someoneelse.com/post',
        ],
    })

    assert sorted(
        mf2util.classify_comment(
            blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')))\
        == ['like', 'repost']
Пример #14
0
def test_multimodal():
    """a mention can have more than one classification, make sure we find
    all of them. also tests some of the alternate/historical classnames"""
    blob = copy.deepcopy(TEST_BLOB)

    # add some references
    blob['items'][1]['properties'].update({
        'reply-to': ['http://noone.im/'],
        'repost-of': [
            'http://someoneelse.com',
            'http://mydomain.com/my-post',
        ],
        'like': [
            'http://mydoma.in/short',
            'http://someoneelse.com/post',
        ],
    })

    assert sorted(
        mf2util.classify_comment(
            blob, ('http://mydoma.in/short', 'http://mydomain.com/my-post')))\
        == ['like', 'repost']