def test_dont_send_to_the_same_user():
    """Tests that if the parent user and the annotation user is the same
    then this function returns False"""
    annotation = _fake_anno(3)
    data = {'parent': _fake_anno(0), 'subscription': {'id': 1}}

    send = rt.check_conditions(annotation, data)
    assert send is False
Beispiel #2
0
def test_dont_send_if_parent_is_missing():
    """Tests that this function returns False if the annotations parent's user is missing"""
    with patch("h.notification.reply_template.Annotation") as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[3]
        data = {"parent": rt.parent_values(annotation), "subscription": {"id": 1}}

        send = rt.check_conditions(annotation, data)
        assert send is False
Beispiel #3
0
def test_good_conditions():
    """If conditions match, this function returns with a True value"""
    with patch("h.notification.reply_template.Annotation") as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[1]
        data = {"parent": rt.parent_values(annotation), "subscription": {"id": 1, "uri": "acct:[email protected]"}}

        send = rt.check_conditions(annotation, data)
        assert send is True
Beispiel #4
0
def test_dont_send_to_the_same_user():
    """Tests that if the parent user and the annotation user is the same
    then this function returns False"""
    with patch("h.notification.reply_template.Annotation") as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[0]
        data = {"parent": rt.parent_values(annotation), "subscription": {"id": 1}}

        send = rt.check_conditions(annotation, data)
        assert send is False
Beispiel #5
0
def test_dont_send_to_the_same_user():
    """Tests that if the parent user and the annotation user is the same
    then this function returns False"""
    annotation = _fake_anno(3)
    data = {
        'parent': _fake_anno(0),
        'subscription': {'id': 1}
    }

    send = rt.check_conditions(annotation, data)
    assert send is False
Beispiel #6
0
def test_dont_send_if_parent_is_missing():
    """Tests that this function returns False if the annotations parent's user is missing"""
    with patch('h.notification.reply_template.Annotation') as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[3]
        data = {
            'parent': rt.parent_values(annotation),
            'subscription': {'id': 1}
        }

        send = rt.check_conditions(annotation, data)
        assert send is False
Beispiel #7
0
def test_different_subscription():
    """If subscription.uri is different from user, do not send!"""
    with patch("h.notification.reply_template.Annotation") as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[1]
        data = {
            "parent": rt.parent_values(annotation),
            "subscription": {"id": 1, "uri": "acct:[email protected]"},
        }

        send = rt.check_conditions(annotation, data)
        assert send is False
Beispiel #8
0
def test_good_conditions():
    """If conditions match, this function returns with a True value"""
    annotation = _fake_anno(1)
    data = {
        'parent': _fake_anno(0),
        'subscription': {
            'id': 1,
            'uri': 'acct:[email protected]'
        }
    }

    send = rt.check_conditions(annotation, data)
    assert send is True
Beispiel #9
0
def test_different_subscription():
    """If subscription.uri is different from user, do not send!"""
    annotation = _fake_anno(1)
    data = {
        'parent': _fake_anno(0),
        'subscription': {
            'id': 1,
            'uri': 'acct:[email protected]'
        }
    }

    send = rt.check_conditions(annotation, data)
    assert send is False
Beispiel #10
0
def test_good_conditions():
    """If conditions match, this function returns with a True value"""
    annotation = _fake_anno(1)
    data = {
        'parent': _fake_anno(0),
        'subscription': {
            'id': 1,
            'uri': 'acct:[email protected]'
        }
    }

    send = rt.check_conditions(annotation, data)
    assert send is True
Beispiel #11
0
def test_different_subscription():
    """If subscription.uri is different from user, do not send!"""
    annotation = _fake_anno(1)
    data = {
        'parent': _fake_anno(0),
        'subscription': {
            'id': 1,
            'uri': 'acct:[email protected]'
        }
    }

    send = rt.check_conditions(annotation, data)
    assert send is False
Beispiel #12
0
def test_dont_send_to_the_same_user():
    """Tests that if the parent user and the annotation user is the same
    then this function returns False"""
    with patch('h.notification.reply_template.Annotation') as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[0]
        data = {
            'parent': rt.parent_values(annotation),
            'subscription': {'id': 1}
        }

        send = rt.check_conditions(annotation, data)
        assert send is False
Beispiel #13
0
def test_good_conditions():
    """If conditions match, this function returns with a True value"""
    with patch('h.notification.reply_template.Annotation') as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[1]
        data = {
            'parent': rt.parent_values(annotation),
            'subscription': {
                'id': 1,
                'uri': 'acct:[email protected]'
            }
        }

        send = rt.check_conditions(annotation, data)
        assert send is True
Beispiel #14
0
def test_different_subscription():
    """If subscription.uri is different from user, do not send!"""
    with patch('h.notification.reply_template.Annotation') as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[1]
        data = {
            'parent': rt.parent_values(annotation),
            'subscription': {
                'id': 1,
                'uri': 'acct:[email protected]'
            }
        }

        send = rt.check_conditions(annotation, data)
        assert send is False
Beispiel #15
0
def test_good_conditions():
    """If conditions match, this function returns with a True value"""
    with patch('h.notification.reply_template.Annotation') as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[1]
        data = {
            'parent': rt.parent_values(annotation),
            'subscription': {
                'id': 1,
                'uri': 'acct:[email protected]'
            }
        }

        send = rt.check_conditions(annotation, data)
        assert send is True
Beispiel #16
0
def test_different_subscription():
    """If subscription.uri is different from user, do not send!"""
    with patch('h.notification.reply_template.Annotation') as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)

        annotation = store_fake_data[1]
        data = {
            'parent': rt.parent_values(annotation),
            'subscription': {
                'id': 1,
                'uri': 'acct:[email protected]'
            }
        }

        send = rt.check_conditions(annotation, data)
        assert send is False
Beispiel #17
0
def test_dont_send_to_the_same_user():
    """Tests that if the parent user and the annotation user is the same
    then this function returns False"""
    with patch('h.notification.reply_template.Annotation') as mock_annotation:
        mock_annotation.fetch = MagicMock(side_effect=fake_fetch)
        request = DummyRequest()
        request.domain = 'www.howtoreachtheark.now'

        annotation = store_fake_data[0]
        data = {
            'parent': rt.parent_values(annotation),
            'subscription': {'id': 1}
        }

        send = rt.check_conditions(annotation, data)
        assert send is False