def setUp(self):
        self.request = make_request()
        self.config = testing.setUp()
        self.config.add_route("bundles_documents",
                              pattern="/bundles/{bundle_id}/documents")

        # register a issue
        self.request.matchdict = {"bundle_id": "example-bundle-id"}
        self.request.validated = apptesting.documents_bundle_registry_data_fixture(
        )
        restfulapi.put_documents_bundle(self.request)
 def test_put_documents_bundle_calls_create_documents_bundle(self):
     self.request.matchdict["bundle_id"] = "0034-8910-rsp-48-2"
     self.request.validated = apptesting.documents_bundle_registry_data_fixture(
     )
     expected = deepcopy(self.request.validated)
     MockCreateDocumentsBundle = Mock()
     self.request.services[
         "create_documents_bundle"] = MockCreateDocumentsBundle
     restfulapi.put_documents_bundle(self.request)
     MockCreateDocumentsBundle.assert_called_once_with("0034-8910-rsp-48-2",
                                                       metadata=expected)
 def test_put_documents_bundle_returns_201_if_created(self):
     self.request.matchdict["bundle_id"] = "0034-8910-rsp-48-2"
     self.request.validated = apptesting.documents_bundle_registry_data_fixture(
     )
     self.request.services["create_documents_bundle"] = Mock()
     response = restfulapi.put_documents_bundle(self.request)
     self.assertIsInstance(response, HTTPCreated)
 def test_put_documents_bundle_returns_204_if_already_exists(self):
     self.request.matchdict["bundle_id"] = "0034-8910-rsp-48-2"
     self.request.validated = apptesting.documents_bundle_registry_data_fixture(
     )
     MockCreateDocumentsBundle = Mock(
         side_effect=exceptions.AlreadyExists("Already Exists"))
     self.request.services[
         "create_documents_bundle"] = MockCreateDocumentsBundle
     response = restfulapi.put_documents_bundle(self.request)
     self.assertIsInstance(response, HTTPNoContent)