<s> from pyramid . testing import DummyRequest <EOL> import pytest <EOL> from h import links <EOL> class FakeAnnotation ( object ) : <EOL> def __init__ ( self ) : <EOL> self . id = '<STR_LIT>' <EOL> self . references = None <EOL> self . target_uri = '<STR_LIT>' <EOL> def test_incontext_link ( api_request ) : <EOL> annotation = FakeAnnotation ( ) <EOL> link = links . incontext_link ( api_request , annotation ) <EOL> assert link == '<STR_LIT>' <EOL> def test_incontext_link_is_none_for_replies ( api_request ) : <EOL> annotation = FakeAnnotation ( ) <EOL> annotation . references = [ '<STR_LIT>' ] <EOL> link = links . incontext_link ( api_request , annotation ) <EOL> assert link is None <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ <EOL> ( None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> def test_incontext_link_appends_schemaless_uri_if_present ( api_request , <EOL> target_uri , <EOL> expected ) : <EOL> annotation = FakeAnnotation ( ) <EOL> annotation . target_uri = target_uri <EOL> link = links . incontext_link ( api_request , annotation ) <EOL> assert link == expected <EOL> @ pytest . fixture <EOL> def api_request ( ) : <EOL> def feature ( name ) : <EOL> return name == '<STR_LIT>' <EOL> request = DummyRequest ( feature = feature ) <EOL> request . registry . settings = { '<STR_LIT>' : '<STR_LIT>' } <EOL> return request </s>
