Ejemplo n.º 1
0
def test_og_no_document(render_app_html, pyramid_request):
    annotation = Annotation(id='123', userid='foo', target_uri='http://example.com')

    render_app_html.return_value = '<html></html>'
    main.annotation_page(annotation, pyramid_request)
    args, kwargs = render_app_html.call_args
    test = lambda d: 'foo' in d['content']
    assert any(test(d) for d in kwargs['extra']['meta_attrs'])
Ejemplo n.º 2
0
def test_og_document(render_app_html, annotation_document, document_title, pyramid_request):
    annotation = Annotation(id='123', userid='foo', target_uri='http://example.com')
    document = Document()
    annotation_document.return_value = document
    document_title.return_value = 'WikiHow — How to Make a ☆Starmap☆'

    render_app_html.return_value = '<html></html>'
    main.annotation_page(annotation, pyramid_request)
    args, kwargs = render_app_html.call_args
    test = lambda d: 'foo' in d['content'] and 'Starmap' in d['content']
    assert any(test(d) for d in kwargs['extra']['meta_attrs'])
Ejemplo n.º 3
0
def test_og_no_document(pyramid_request, group_service, links_service, sidebar_app):
    annotation = Annotation(id='123', userid='foo', target_uri='http://example.com')
    context = AnnotationResource(annotation, group_service, links_service)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    def test(d):
        return 'foo' in d['content']
    assert any(test(d) for d in ctx['meta_attrs'])
Ejemplo n.º 4
0
def test_og_document(factories, pyramid_request, group_service, links_service, sidebar_app):
    annotation = factories.Annotation(userid='acct:[email protected]')
    context = AnnotationResource(annotation, group_service, links_service)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    def test(d):
        return '*****@*****.**' in d['content'] and annotation.document.title in d['content']
    assert any(test(d) for d in ctx['meta_attrs'])
Ejemplo n.º 5
0
def test_og_no_document(pyramid_request, group_service, links_service, sidebar_app):
    annotation = Annotation(id="123", userid="foo", target_uri="http://example.com")
    context = AnnotationContext(annotation, group_service, links_service)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    def test(d):
        return "foo" in d["content"]

    assert any(test(d) for d in ctx["meta_attrs"])
Ejemplo n.º 6
0
def test_og_no_document(
    pyramid_request, groupfinder_service, links_service, sidebar_app
):
    annotation = Annotation(id="123", userid="foo", target_uri="http://example.com")
    context = AnnotationContext(annotation, groupfinder_service, links_service)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    expected = Any.dict.containing({"content": Any.string.containing("foo")})

    assert expected in ctx["meta_attrs"]
Ejemplo n.º 7
0
def test_og_document(factories, pyramid_request, group_service, links_service,
                     sidebar_app):
    annotation = factories.Annotation(userid="acct:[email protected]")
    context = AnnotationContext(annotation, group_service, links_service)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    def test(d):
        return ("*****@*****.**" in d["content"]
                and annotation.document.title in d["content"])

    assert any(test(d) for d in ctx["meta_attrs"])
Ejemplo n.º 8
0
def test_og_no_document(pyramid_request, group_service, links_service,
                        sidebar_app):
    annotation = Annotation(id="123",
                            userid="foo",
                            target_uri="http://example.com")
    context = AnnotationContext(annotation, group_service, links_service)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    def test(d):
        return "foo" in d["content"]

    assert any(test(d) for d in ctx["meta_attrs"])
Ejemplo n.º 9
0
def test_og_document(annotation_document, document_title, pyramid_request,
                     group_service, links_service, sidebar_app):
    annotation = Annotation(id='123', userid='foo', target_uri='http://example.com')
    context = AnnotationResource(annotation, group_service, links_service)
    document = Document()
    annotation_document.return_value = document
    document_title.return_value = 'WikiHow — How to Make a ☆Starmap☆'
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    def test(d):
        return 'foo' in d['content'] and 'Starmap' in d['content']
    assert any(test(d) for d in ctx['meta_attrs'])
Ejemplo n.º 10
0
def test_og_document(factories, pyramid_request, sidebar_app):
    annotation = factories.Annotation(userid="acct:[email protected]")
    context = AnnotationContext(annotation)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    expected = Any.dict.containing({
        "content":
        All.of([
            Any.string.containing("*****@*****.**"),
            Any.string.containing(annotation.document.title),
        ])
    })

    assert expected in ctx["meta_attrs"]
Ejemplo n.º 11
0
def test_og_document(
    factories, pyramid_request, group_service, links_service, sidebar_app
):
    annotation = factories.Annotation(userid="acct:[email protected]")
    context = AnnotationContext(annotation, group_service, links_service)
    sidebar_app.side_effect = _fake_sidebar_app

    ctx = main.annotation_page(context, pyramid_request)

    def test(d):
        return (
            "*****@*****.**" in d["content"]
            and annotation.document.title in d["content"]
        )

    assert any(test(d) for d in ctx["meta_attrs"])