Tests for WebDAV operations
===========================

First, setup some content with references:

  >>> portal = layer['portal']
  >>> from plone.app.testing import TEST_USER_ID
  >>> from plone.app.testing import TEST_USER_NAME as user_name
  >>> from plone.app.testing import TEST_USER_PASSWORD as user_password
  >>> folder = portal.portal_membership.getHomeFolder(TEST_USER_ID)
  >>> from Products.Archetypes.tests.utils import makeContent

  >>> a = makeContent(folder, portal_type='DDocument', title='Foo', id='a')
  >>> b = makeContent(folder, portal_type='DDocument', title='Bar', id='b')

  >>> f = makeContent(folder, portal_type='Folder', title='Sub', id='f')

  >>> _ = a.addReference(b, "KnowsAbout")
  >>> _ = b.addReference(a, "KnowsAbout")

  >>> a.getRefs()
  [<DDocument at /.../b>]

  >>> b.getRefs()
  [<DDocument at /.../a>]

Now do a WebDAV COPY and check that the references were removed from
the copy:

  >>> from Testing.ZopeTestCase.zopedoctest.functional import http
  >>> from Testing.ZopeTestCase.sandbox import AppZapper 
  >>> AppZapper().set(layer['app'])
  >>> print http(r"""
  ... COPY %s HTTP/1.1
  ... Destination: %s
  ... Authorization: Basic %s:%s
  ... """ % ('/'.join(a.getPhysicalPath()),
  ...        '/'.join(f.getPhysicalPath() + ('a',)),
  ...        user_name, user_password),
  ...        handle_errors=True)
  HTTP/1.1 201 Created
  ...

  >>> a.getRefs()
  [<DDocument at /.../b>]

  >>> b.getRefs()
  [<DDocument at /.../a>]

  >>> f['a'].getRefs()
  []

Do a WebDAV move with 'b' and make sure it keeps the references:

  >>> print http(r"""
  ... MOVE %s HTTP/1.1
  ... Destination: %s
  ... Authorization: Basic %s:%s
  ... """ % ('/'.join(b.getPhysicalPath()),
  ...        '/'.join(f.getPhysicalPath() + ('b',)),
  ...        user_name, user_password),
  ...        handle_errors=True)
  HTTP/1.1 201 Created
  ...

  >>> a.getRefs()
  [<DDocument at /.../b>]

  >>> f['a'].getRefs()
  []

  >>> f['b'].getRefs()
  [<DDocument at /.../a>]

Clean up
  >>> AppZapper().clear()
