def test_admin_link_field_force_view_name(self, mock_reverse): """It should be possible to force the view name used to reverse the url.""" method = link_field("my_field", view_name="my_view") self.assertEqual( method(Obj()), '<a target="_blank" href="my-url">My Linked Object</a>' ) mock_reverse.assert_called_once_with("my_view", args=[1])
def test_admin_link_field_target_blank(self, mock_reverse): """ It should be possible to disable the blank target. """ method = link_field("my_field", target_blank=False) self.assertEqual(method(Obj()), '<a href="my-url">My Linked Object</a>') mock_reverse.assert_called_once_with( "admin:app-label_model-name_change", args=[1] )
def test_admin_link_field_force_anchor(self, mock_reverse): """It should be possible to force the anchor.""" method = link_field("my_field", anchor="My Forced Anchor") self.assertEqual( method(Obj()), '<a target="_blank" href="my-url">My Forced Anchor</a>' ) mock_reverse.assert_called_once_with( "admin:app-label_model-name_change", args=[1] )
def test_admin_link_field(self, mock_reverse): """ It should compute the reverse url of the object pointed by the field passed in argument. """ method = link_field("my_field") self.assertEqual( method(Obj()), '<a target="_blank" href="my-url">My Linked Object</a>' ) mock_reverse.assert_called_once_with( "admin:app-label_model-name_change", args=[1] )