'Helper method which makes an API call to delete the supplied
``dataset`` from ``origin`` and finally asserts that the API call
returned the expected result and that the persistence_service has
been updated.
:param Dataset dataset: The dataset which will be deleted.
:param if_matches: If not ``None``, a value to send in
``X-If-Configuration-Matches`` header.
:returns: A ``Deferred`` which fires when all assertions have been
executed.'

def _test_delete(self, dataset, if_matches=None):

    deployment = self.persistence_service.get()
    expected_dataset_id = dataset.dataset_id
    origin = next(iter(deployment.nodes.values()))
    expected_dataset = {u'dataset_id': expected_dataset_id, u'primary': unicode(origin.uuid), u'metadata': {}, u'deleted': True}
    headers = {}
    if (if_matches is not None):
        headers[IF_MATCHES_HEADER] = [if_matches]
    deleting = self.assertResult('DELETE', ('/configuration/datasets/%s' % (expected_dataset_id.encode('ascii'),)), None, OK, expected_dataset, additional_headers=headers)
    def got_result(result):
        deployment = self.persistence_service.get()
        for node in deployment.nodes.values():
            if same_node(node, origin):
                dataset_ids = [(m.dataset.deleted, m.dataset.dataset_id) for m in node.manifestations.values()]
                self.assertIn((True, expected_dataset_id), dataset_ids)
                break
        else:
            self.fail('Node    not    found.    {}'.format(node.uuid))
    deleting.addCallback(got_result)
    return deleting
