Let's explore and test quills.trackback.interfaces...

The test-case class should have made self.obj_4tb and self.obj_not4tb available
to us.  We'll check that (and save a few keystrokes in this file) and make sure
they implement the correct interfaces.

  >>> obj_4tb = self.obj_4tb
  >>> obj_not4tb = self.obj_not4tb
  >>> from quills.trackback.interfaces import ITrackbackable
  >>> ITrackbackable.providedBy(obj_4tb)
  True
  >>> ITrackbackable.providedBy(obj_not4tb)
  False

Now, we should be able to send a trackback ping to obj_4tb, and not to
obj_not4tb.  We'll simulate a request object for a trackback ping.

  >>> from zope.publisher.browser import TestRequest
  >>> tbdict = {  'title'           :   'the post title'
  ...           , 'excerpt'         :   'the excerpt'
  ...           , 'url'             :   'http://www.example.com/'
  ...           , 'blog_name'       :   'the site title'
  ...           }
  >>> headers = {
  ...             'REMOTE_ADDR'     :   '127.0.0.1'
  ...           , 'User-Agent'      :   'a test user agent'
  ...           , 'HTTP_REFERRER'   :   'http://www.example.com/a-referrer/'
  ...           }
  >>> request = TestRequest(form=tbdict, **headers)

A few quick sanity checks.

  >>> request.get('blog_name')
  'the site title'
  >>> request.get('REMOTE_ADDR')
  '127.0.0.1'
  >>> request['HTTP_REFERRER']
  'http://www.example.com/a-referrer/'

Let's lookup the trackback receiver view for our objects.

  >>> from zope.component import queryMultiAdapter
  >>> v = queryMultiAdapter((obj_not4tb, request), name='trackback', default=None)
  >>> v is None
  True

Good, the non-trackbackable object doesn't have the trackback receiver view.
The trackbackable object should, though.

  >>> receiver_view = queryMultiAdapter((obj_4tb, request), name='trackback')
  >>> receiver_view is not None
  True

Some sanity checks on the request processing code.

  >>> tb0 = receiver_view.trackbackFromRequest()
  >>> tb0.getTitle()
  'the post title'
  >>> tb0.getUserIP()
  '127.0.0.1'
  >>> tb0.getSiteTitle()
  'the site title'
  >>> tb0.getUserAgent()
  'a test user agent'
  >>> tb0.getReferrer()
  'http://www.example.com/a-referrer/'

The receiver_view can now process the incoming ping that it finds in the
request.

  >>> receiver_view.receiveTrackbackPing()

We'd like to check that the trackback is available from the object.  So, let's
adapt to ITrackbackInManager and see.

  >>> from quills.trackback.interfaces import ITrackbackInManager
  >>> tbim = ITrackbackInManager(obj_4tb)

There should only be one ping in there now... that implements appropriately.

  >>> tbs = tbim.getAcceptedTrackbacks()
  >>> len(tbs)
  1
  >>> tb = tbs[0]
  >>> from quills.trackback.interfaces import IWorkflowedTrackback
  >>> IWorkflowedTrackback.providedBy(tb)
  True

Do all the values correspond to what we set on the request?

  >>> tb = tbs[0]
  >>> tb.getExcerpt()
  'the excerpt'
  >>> tb.getTitle()
  'the post title'
  >>> tb.getSiteTitle()
  'the site title'
  >>> tb.getURL()
  'http://www.example.com/'
  >>> tb.getUserAgent()
  'a test user agent'
  >>> tb.getReferrer()
  'http://www.example.com/a-referrer/'

It should be possible to get hold of the original object being pinged from the
trackback itself.

  >>> tb.getPingedObject().getPhysicalPath() == obj_4tb.getPhysicalPath()
  True
