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
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
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
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
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
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
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
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
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
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
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
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
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