def test_10_advanced_retrieve_deposit_receipt(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          on_behalf_of=SSS_OBO)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip',
                in_progress=True,
                suggested_identifier="0987654321")

        # we're going to work with the location
        assert receipt.location != None

        new_receipt = conn.get_deposit_receipt(receipt.location)

        assert new_receipt.code == 200
        assert new_receipt.parsed == True
        assert new_receipt.valid == True
 def test_15_Metadata_POST_to_sss_w_coliri(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     dr = conn.create(metadata_entry = e,
                                 col_iri = conn.sd.workspaces[0][1][0].href, 
                                 in_progress=True)
     assert dr.code == 201
 def test_30_advanced_add_multipart(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="Multipart deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href,
                     metadata_entry = e,
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip')
     
     # ensure that we have a receipt (the server may not give us one
     # by default)
     receipt = conn.get_deposit_receipt(receipt.location)
     
     ne = Entry(title="Multipart deposit", id="asidjasidj", dcterms_identifier="http://another/",
                 dcterms_creator="Me!", dcterms_rights="CC0")
     with open(PACKAGE) as pkg:
         new_receipt = conn.append(dr=receipt,
                                     metadata_entry=ne,
                                     payload=pkg, 
                                     filename="addition.zip", 
                                     mimetype=PACKAGE_MIME,
                                     packaging="http://purl.org/net/sword/package/SimpleZip",
                                     in_progress=True,
                                     metadata_relevant=True)
         
     assert new_receipt.code >= 200 and new_receipt.code < 400
 def test_21_advanced_replace_with_multipart(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="Multipart deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href,
                     metadata_entry = e,
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip')
                     
     # ensure that we have a receipt (the server may not give us one
     # by default)
     receipt = conn.get_deposit_receipt(receipt.location)
     
     # now do the replace
     ne = Entry(title="A multipart update", id="asidjasidj", dcterms_abstract="new abstract", dcterms_identifier="http://elsewhere/")
     with open(PACKAGE) as pkg:
         new_receipt = conn.update(dr = receipt,
                         metadata_entry = ne,
                         payload=pkg,
                         mimetype=PACKAGE_MIME,
                         filename="update.zip",
                         packaging='http://purl.org/net/sword/package/SimpleZip',
                         in_progress=True)
     
     assert new_receipt.code == 204 or new_receipt.code == 200
     if new_receipt.code == 204:
         assert new_receipt.dom is None
     if new_receipt.code == 200:
         assert new_receipt.parsed == True
         assert new_receipt.valid == True
 def test_17_advanced_replace_file_content(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href, 
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging='http://purl.org/net/sword/package/SimpleZip')
     # ensure that we have a receipt (the server may not give us one
     # by default)
     receipt = conn.get_deposit_receipt(receipt.location)
     
     # now do the replace
     with open(PACKAGE) as pkg:
         new_receipt = conn.update(dr = receipt,
                         payload=pkg,
                         mimetype=PACKAGE_MIME,
                         filename="update.zip",
                         packaging='http://purl.org/net/sword/package/SimpleZip',
                         metadata_relevant=True)
     
     assert new_receipt.code == 204
     assert new_receipt.dom is None
 def test_15_retrieve_content_em_iri_as_feed(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href, 
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging='http://purl.org/net/sword/package/SimpleZip')
     # ensure that we have a receipt (the server may not give us one
     # by default)
     receipt = conn.get_deposit_receipt(receipt.location)
     
     # we're going to work with the edit_media_feed iri
     assert receipt.edit_media_feed is not None
     
     response = conn.get_resource(content_iri=receipt.edit_media_feed)
     
     assert response.code == 200
     assert response.content is not None
     
     # the response should be an xml document, so let's see if we can parse
     # it.  This should give us an exception which will fail the test if not
     dom = etree.fromstring(response.content)
Exemple #7
0
	def __init__(self, owner):
		raise NotImplementedError
		c = Connection(SD_URI, user_name = owner.username, user_pass=owner.password)
		c.get_service_document()

		# pick the first collection within the first workspace:
		workspace_1_title, workspace_1_collections = c.workspaces[0]
		collection = workspace_1_collections[0]

		# upload "package.zip" to this collection as a new (binary) resource:
		with open("package.zip", "r") as pkg:
		    receipt = c.create(col_iri = collection.href,
		                                payload = pkg,
		                                mimetype = "application/zip",
		                                filename = "package.zip",
		                                packaging = 'http://purl.org/net/sword/package/Binary',
		                                in_progress = True)    # As the deposit isn't yet finished


		# Add a metadata record to this newly created resource (or 'container')
		from sword2 import Entry
		# Entry can be passed keyword parameters to add metadata to the entry (namespace + '_' + tagname)
		e = Entry(id="atomid", 
		          title="atom-title",
		          dcterms_abstract = "Info about the resource....",
		          )
		# to add a new namespace:
		e.register_namespace('skos', 'http://www.w3.org/2004/02/skos/core#')
		e.add_field("skos_Concept", "...")


		# Update the metadata entry to the resource:
		updated_receipt = c.update(metadata_entry = e,
		                           dr = receipt,   # use the receipt to discover the right URI to use
		                           in_progress = False)  # finish the deposit
 def test_31_delete_container(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO,
                         error_response_raises_exceptions=False)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     #e = Entry(title="Multipart deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href,
                     #metadata_entry = e,
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip')
     
     # ensure that we have a receipt (the server may not give us one
     # by default)
     edit_iri = receipt.location
     receipt = conn.get_deposit_receipt(edit_iri)
     
     # delete the container
     new_receipt = conn.delete_container(dr=receipt)
     
     assert new_receipt.code == 204
     assert new_receipt.dom is None
     
     # the next check is that this 404s appropriately now
     another_receipt = conn.get_deposit_receipt(edit_iri)
    def test_16_basic_replace_file_content(self):
        conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip',
                in_progress=True)
        # ensure that we have a receipt (the server may not give us one
        # by default)
        receipt = conn.get_deposit_receipt(receipt.location)

        # now do the replace
        with open(PACKAGE) as pkg:
            new_receipt = conn.update(
                dr=receipt,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="update.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')

        assert new_receipt.code == 204
        assert new_receipt.dom is None
    def preflight_submission(self):
        opener = self.get_opener()
        
        conn = Connection(self.sword2_sd_url, error_response_raises_exceptions=False, http_impl=UrlLib2Layer(opener))
        logger.debug("Retrieving the service document")
        conn.get_service_document()
        
        logger.debug("Retrieved the service document")
        
        self.assertIsNotNone(conn.sd)
        self.assertIsNotNone(conn.sd.workspaces)
        self.assertNotEqual(len(conn.sd.workspaces),0)
        
        
        workspace = conn.sd.workspaces[0][1]
        
        # we require there to be at least one collection
        self.assertNotEqual(len(workspace),0)
        col = workspace[0]
        

        testid = "testid_"+str(uuid.uuid4())
        logger.debug("col iri = " + str(col.href))
        
        e = Entry(id=testid, title="test title", dcterms_abstract="test description")
        print str(e)
        receipt = conn.create(col_iri=col.href, metadata_entry=e, suggested_identifier=testid)
        #col.href=http://192.168.2.237/swordv2/silo/test-silo
        self.assertIsNotNone(receipt)
        self.assertEquals(receipt.code,201)
        return receipt.location
    def test_15_retrieve_content_em_iri_as_feed(self):
        conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')
        # ensure that we have a receipt (the server may not give us one
        # by default)
        receipt = conn.get_deposit_receipt(receipt.location)

        # we're going to work with the edit_media_feed iri
        assert receipt.edit_media_feed is not None

        response = conn.get_resource(content_iri=receipt.edit_media_feed)

        assert response.code == 200
        assert response.content is not None

        # the response should be an xml document, so let's see if we can parse
        # it.  This should give us an exception which will fail the test if not
        dom = etree.fromstring(response.content)
    def test_14_error_retrieve_content_em_iri(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          honour_receipts=False,
                          error_response_raises_exceptions=False)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')
        # ensure that we have a receipt (the server may not give us one
        # by default)
        receipt = conn.get_deposit_receipt(receipt.location)

        error = 'http://purl.org/net/sword/package/IJustMadeThisUp'
        response = conn.get_resource(content_iri=receipt.edit_media,
                                     packaging=error)

        assert response.code == 406
        assert isinstance(response, Error_Document)
        assert response.error_href == "http://purl.org/net/sword/error/ErrorContent"
    def test_13_advanced_retrieve_content_em_iri(self):
        conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')
        # ensure that we have a receipt (the server may not give us one
        # by default)
        receipt = conn.get_deposit_receipt(receipt.location)

        packaging = 'http://purl.org/net/sword/package/SimpleZip'
        if receipt.packaging is not None and len(receipt.packaging) > 0:
            packaging = receipt.packaging[0]

        resource = conn.get_resource(content_iri=receipt.edit_media,
                                     packaging=packaging,
                                     on_behalf_of=SSS_OBO)

        assert resource.code == 200
        assert resource.content is not None
    def test_06_advanced_create_resource_with_multipart(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          on_behalf_of=SSS_OBO)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        e = Entry(title="Foo",
                  id="asidjasidj",
                  dcterms_abstract="abstract",
                  dcterms_title="my title")
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                metadata_entry=e,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip',
                in_progress=True,
                suggested_identifier="zyxwvutsrq")

        assert receipt.code == 201
        assert receipt.location != None

        # these last two assertions are contingent on if we actually get a
        # receipt back from the server (which we might not legitimately get)
        assert receipt.dom is None or receipt.parsed == True
        assert receipt.dom is None or receipt.valid == True
 def test_12_Metadata_POST_to_sss(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     resp = conn.create(metadata_entry = e,
                                 workspace='Main Site', 
                                 collection=conn.sd.workspaces[0][1][0].title, 
                                 in_progress=True)
     assert resp != None
Exemple #16
0
    def preflight_submission(self, dataset, opener, repository, silo ):
        logger.debug("Carrying out pre-flight submission")
        
        # verify that we can get a service document, and that there
        # is at least one silo and that we can authenticate
        
        if repository.sword2_sd_url is None:
            raise SwordServiceError("No sword2 service-document URL for repository configuration")
            
        # get the service document (for which we must be authenticated)
        conn = Connection(repository.sword2_sd_url, error_response_raises_exceptions=False, http_impl=UrlLib2Layer(opener))
        conn.get_service_document()
        
        # we require there to be at least one workspace
        if conn.sd is None:
            raise SwordServiceError("did not successfully retrieve a service document")
        
        if conn.sd.workspaces is None:
            raise SwordServiceError("no workspaces defined in service document")
        
        if len(conn.sd.workspaces) == 0:
            raise SwordServiceError("no workspaces defined in service document")
        
        workspace = conn.sd.workspaces[0][1]
        
        # we require there to be at least one collection
        if len(workspace) == 0:
            raise SwordServiceError("no collections defined in workspace")
            
        # FIXME: we don't currently have a mechanism to make decisions about
        # which collection to put stuff in, so we just put stuff in the first
        # one for the time being
        col = workspace[0]
        silohref = repository.homepage + "swordv2/silo/" + silo

        # assemble the entry ready for deposit, using the basic metadata
        # FIXME: is there anything further we need to do about the metadata here?
        e = Entry(id=dataset.identifier, title=dataset.title, dcterms_abstract=dataset.description)
        
        # create the item using the metadata-only approach (suppress errors along the way,
        # we'll check for them below)
        #receipt = conn.create(col_iri=col.href, metadata_entry=e, suggested_identifier=dataset.identifier)
        logger.debug( "Deposit is being created" )
        receipt = conn.create(col_iri=silohref, metadata_entry=e, suggested_identifier=dataset.identifier)
        logger.debug( "Deposit created" )
        # check for errors
        if receipt.code >= 400:
            # this is an error
            logger.debug("Received error message from server: " + receipt.to_xml())
            if receipt.error_href == "http://databank.ox.ac.uk/errors/DatasetConflict":
                raise SwordSlugRejected()
            raise SwordDepositError(receipt)
        
        logger.debug("Deposit carried out to: " + receipt.location)
        # return receipt.location
        return (receipt.alternate,receipt.location)
    def test_34_check_metadata_only_state(self):
        conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
        receipt = conn.create(col_iri = col.href, metadata_entry = e)
        statement = conn.get_ore_sword_statement(receipt.ore_statement_iri)

        assert len(statement.states) == 1
        assert statement.states[0][0] == "http://databank.ox.ac.uk/state/EmptyContainer"
    def test_34_check_metadata_only_state(self):
        conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
        receipt = conn.create(col_iri = col.href, metadata_entry = e)
        statement = conn.get_ore_sword_statement(receipt.ore_statement_iri)

        assert len(statement.states) == 1
        assert statement.states[0][0] == "http://databank.ox.ac.uk/state/EmptyContainer"
 def test_08_Simple_POST_to_sss_w_coliri(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     resp = conn.create(payload = "Payload is just a load of text", 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary',
                                 col_iri = conn.sd.workspaces[0][1][0].href, 
                                 in_progress=True, 
                                 metadata_entry=None)
     assert resp.code == 201
 def test_06_Simple_POST_to_sss(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     resp = conn.create(payload = "Payload is just a load of text", 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary', 
                                 workspace = 'Main Site', 
                                 collection = conn.sd.workspaces[0][1][0].title, 
                                 in_progress=True, 
                                 metadata_entry=None)
     assert resp.code == 201
 def test_07_Multipart_POST_to_sss(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     resp = conn.create(payload = "Multipart payload here", 
                                 metadata_entry = e, 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary', 
                                 workspace='Main Site', 
                                 collection=conn.sd.workspaces[0][1][0].title, 
                                 in_progress=True)
     assert resp.code == 201
 def test_22_Create_deposit_and_delete_deposit(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     deposit_receipt = conn.create(payload = "Multipart_POST_then_update_on_EM_IRI", 
                                 metadata_entry = e, 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary',
                                 col_iri = conn.sd.workspaces[0][1][0].href, 
                                 in_progress=True)
     assert deposit_receipt.edit != None
     dr = conn.delete(resource_iri = deposit_receipt.edit)
     assert dr.code == 204 or dr.code == 200
Exemple #23
0
 def test_15_Metadata_POST_to_sss_w_coliri(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     e = Entry(title="Foo",
               id="asidjasidj",
               dcterms_appendix="blah blah",
               dcterms_title="foo bar")
     dr = conn.create(metadata_entry=e,
                      col_iri=conn.sd.workspaces[0][1][0].href,
                      in_progress=True)
     assert dr.code == 201
    def test_10_advanced_retrieve_deposit_receipt(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          on_behalf_of=SSS_OBO)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        suggested_id = str(uuid.uuid4())
        e = Entry(title="An entry only deposit",
                  id="asidjasidj",
                  dcterms_abstract="abstract",
                  dcterms_identifier="http://whatever/")
        receipt = conn.create(col_iri=col.href,
                              metadata_entry=e,
                              in_progress=True,
                              suggested_identifier=suggested_id)

        # we're going to work with the location
        assert receipt.location != None

        new_receipt = conn.get_deposit_receipt(receipt.location)

        assert new_receipt.code == 200
        assert new_receipt.parsed == True
        assert new_receipt.valid == True

        print new_receipt.to_xml()

        # Here are some more things we can know about the receipt
        # 1 - the links will all contain the suggested identifier
        # 2 - the links will all contain the name of the silo
        # 3 - the packaging will contain DataBankBagIt
        # 4 - the DC metadata will be reflected back at us
        # 5 - the atom metadata will be populated in some way

        for rel, links in new_receipt.links.iteritems():
            for link in links:
                assert suggested_id in link['href']
                assert col.title in link['href']

        assert "http://dataflow.ox.ac.uk/package/DataBankBagIt" in new_receipt.packaging

        # check the atom metadata
        assert new_receipt.title == "An entry only deposit"
        assert new_receipt.summary == "abstract"

        # check the DC metadata
        assert "An entry only deposit" in new_receipt.metadata["dcterms_title"]
        assert "abstract" in new_receipt.metadata["dcterms_abstract"]
        assert "http://whatever/" in new_receipt.metadata["dcterms_identifier"]
Exemple #25
0
 def test_12_Metadata_POST_to_sss(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     e = Entry(title="Foo",
               id="asidjasidj",
               dcterms_appendix="blah blah",
               dcterms_title="foo bar")
     resp = conn.create(metadata_entry=e,
                        workspace='Main Site',
                        collection=conn.sd.workspaces[0][1][0].title,
                        in_progress=True)
     assert resp != None
 def test_23_Finish_in_progress_deposit(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     deposit_receipt = conn.create(payload = "Multipart_POST_then_update_on_EM_IRI", 
                                 metadata_entry = e, 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary',
                                 col_iri = conn.sd.workspaces[0][1][0].href, 
                                 in_progress=True)
     assert deposit_receipt.edit != None
     dr = conn.complete_deposit(se_iri = deposit_receipt.se_iri)
     print "This will fail until the sss.py SWORD2 server responds properly, rather than with code 201"
     assert dr.code == 200
 def test_09_basic_retrieve_deposit_receipt(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href, metadata_entry = e)
     
     # we're going to work with the location
     assert receipt.location != None
     
     new_receipt = conn.get_deposit_receipt(receipt.location)
     
     assert new_receipt.code == 200
     assert new_receipt.parsed == True
     assert new_receipt.valid == True
 def test_09_basic_retrieve_deposit_receipt(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href, metadata_entry = e)
     
     # we're going to work with the location
     assert receipt.location != None
     
     new_receipt = conn.get_deposit_receipt(receipt.location)
     
     assert new_receipt.code == 200
     assert new_receipt.parsed == True
     assert new_receipt.valid == True
 def test_07_basic_create_resource_with_entry(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href,
                 metadata_entry = e)
                     
     assert receipt.code == 201
     assert receipt.location != None
     
     # these last two assertions are contingent on if we actually get a 
     # receipt back from the server (which we might not legitimately get)
     assert receipt.dom is None or receipt.parsed == True
     assert receipt.dom is None or receipt.valid == True
 def test_07_basic_create_resource_with_entry(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href,
                 metadata_entry = e)
                     
     assert receipt.code == 201
     assert receipt.location != None
     
     # these last two assertions are contingent on if we actually get a 
     # receipt back from the server (which we might not legitimately get)
     assert receipt.dom is None or receipt.parsed == True
     assert receipt.dom is None or receipt.valid == True
 def test_17_Simple_POST_and_GET(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     col_iri = conn.sd.workspaces[0][1][0].href  # pick the first collection
     dr = conn.create(payload = "Simple_POST_and_GET", 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary',
                                 col_iri = col_iri, 
                                 in_progress=True, 
                                 metadata_entry=None)
     assert dr.code == 201
     # Now to GET that resource with no prescribed for packaging
     content_object = conn.get_resource(dr.cont_iri)
     # Can't guarantee that sss.py won't mangle submissions, so can't validate response at this moment
     assert content_object != None
Exemple #32
0
 def test_06_Simple_POST_to_sss(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     resp = conn.create(
         payload="Payload is just a load of text",
         mimetype="text/plain",
         filename="readme.txt",
         packaging='http://purl.org/net/sword/package/Binary',
         workspace='Main Site',
         collection=conn.sd.workspaces[0][1][0].title,
         in_progress=True,
         metadata_entry=None)
     assert resp.code == 201
 def test_35_check_new_zip_state(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href, metadata_entry = e)
     with open(PACKAGE) as pkg:
         new_receipt = conn.update(dr = receipt,
                         payload=pkg,
                         mimetype=PACKAGE_MIME,
                         filename="update.zip",
                         packaging='http://purl.org/net/sword/package/SimpleZip')
     statement = conn.get_ore_sword_statement(receipt.ore_statement_iri)
     
     assert len(statement.states) == 1
     assert statement.states[0][0] == "http://databank.ox.ac.uk/state/ZipFileAdded"
 def test_14_Invalid_Packaging_cached_receipt(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True, honour_receipts=True)
     col_iri = conn.sd.workspaces[0][1][0].href  # pick the first collection
     dr = conn.create(payload = "Payload is just a load of text", 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary',
                                 col_iri = col_iri, 
                                 in_progress=True)
     # Now to GET that resource with invalid packaging
     try:
         content = conn.get_resource(dr.cont_iri, packaging="foofar")
         assert 1 == 0   # fail
     except PackagingFormatNotAvailable:
         # test the 'honour_receipts' flag and cached deposit 
         pass
 def test_35_check_new_zip_state(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href, metadata_entry = e)
     with open(PACKAGE) as pkg:
         new_receipt = conn.update(dr = receipt,
                         payload=pkg,
                         mimetype=PACKAGE_MIME,
                         filename="update.zip",
                         packaging='http://purl.org/net/sword/package/SimpleZip')
     statement = conn.get_ore_sword_statement(receipt.ore_statement_iri)
     
     assert len(statement.states) == 1
     assert statement.states[0][0] == "http://databank.ox.ac.uk/state/ZipFileAdded"
 def test_18_Metadata_POST_to_se_iri(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     deposit_receipt = conn.create(payload = "Multipart_POST_then_update_on_EM_IRI", 
                                 metadata_entry = e, 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary',
                                 col_iri = conn.sd.workspaces[0][1][0].href, 
                                 in_progress=True)
                                 
     assert deposit_receipt.se_iri != None
     e.add_fields(dcterms_identifier="doi://somerubbish", dcterms_foo="blah blah")
     dr = conn.append(se_iri = deposit_receipt.se_iri,
                                           metadata_entry = e,
                                           in_progress=False)
     assert dr.code == 200    
    def test_21_advanced_replace_with_multipart(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          on_behalf_of=SSS_OBO,
                          http_impl=http)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        e = Entry(title="Multipart deposit",
                  id="asidjasidj",
                  dcterms_abstract="abstract",
                  dcterms_identifier="http://whatever/")
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                metadata_entry=e,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')

        # ensure that we have a receipt (the server may not give us one
        # by default)
        receipt = conn.get_deposit_receipt(receipt.location)

        # now do the replace
        ne = Entry(title="A multipart update",
                   id="asidjasidj",
                   dcterms_abstract="new abstract",
                   dcterms_identifier="http://elsewhere/")
        with open(PACKAGE) as pkg:
            new_receipt = conn.update(
                dr=receipt,
                metadata_entry=ne,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="update.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip',
                in_progress=True)

        assert new_receipt.code == 204 or new_receipt.code == 200
        if new_receipt.code == 204:
            assert new_receipt.dom is None
        if new_receipt.code == 200:
            assert new_receipt.parsed == True
            assert new_receipt.valid == True
 def test_36_error_bad_request(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW,
                         error_response_raises_exceptions=False)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href,
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip',
                     in_progress = "Invalid",    # the API seems to allow this!
                     suggested_identifier = "zyxwvutsrq")
                     
     assert receipt.code == 400
     assert isinstance(receipt, Error_Document)
     assert receipt.error_href == "http://purl.org/net/sword/error/ErrorBadRequest"
 def test_24_get_sword_statement(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="******", download_service_document=True)
     e = Entry(title="Foo", id="asidjasidj", dcterms_appendix="blah blah", dcterms_title="foo bar")
     deposit_receipt = conn.create(payload = "Multipart_POST_then_update_on_EM_IRI", 
                                 metadata_entry = e, 
                                 mimetype = "text/plain", 
                                 filename = "readme.txt", 
                                 packaging = 'http://purl.org/net/sword/package/Binary',
                                 col_iri = conn.sd.workspaces[0][1][0].href, 
                                 in_progress=True)
     ss_iri = None
     for item_dict in deposit_receipt.links['http://purl.org/net/sword/terms/statement']:
         if item_dict.has_key('type') and item_dict.get('type', None) == "application/atom+xml;type=feed":
             ss_iri = item_dict.get('href')
     assert ss_iri != None
     ss = conn.get_atom_sword_statement(ss_iri)
     assert ss != None
     assert ss.resources[0].deposited_by == 'sword'
Exemple #40
0
 def test_17_Simple_POST_and_GET(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     col_iri = conn.sd.workspaces[0][1][0].href  # pick the first collection
     dr = conn.create(payload="Simple_POST_and_GET",
                      mimetype="text/plain",
                      filename="readme.txt",
                      packaging='http://purl.org/net/sword/package/Binary',
                      col_iri=col_iri,
                      in_progress=True,
                      metadata_entry=None)
     assert dr.code == 201
     # Now to GET that resource with no prescribed for packaging
     content_object = conn.get_resource(dr.cont_iri)
     # Can't guarantee that sss.py won't mangle submissions, so can't validate response at this moment
     assert content_object != None
Exemple #41
0
 def test_08_Simple_POST_to_sss_w_coliri(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     e = Entry(title="Foo",
               id="asidjasidj",
               dcterms_appendix="blah blah",
               dcterms_title="foo bar")
     resp = conn.create(
         payload="Payload is just a load of text",
         mimetype="text/plain",
         filename="readme.txt",
         packaging='http://purl.org/net/sword/package/Binary',
         col_iri=conn.sd.workspaces[0][1][0].href,
         in_progress=True,
         metadata_entry=None)
     assert resp.code == 201
 def test_03_basic_create_resource_with_package(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href, 
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip')
                     
     assert receipt.code == 201
     assert receipt.location != None
     
     # these last two assertions are contingent on if we actually get a 
     # receipt back from the server (which we might not legitimately get)
     assert receipt.dom is None or receipt.parsed == True
     assert receipt.dom is None or receipt.valid == True
 def test_37_error_target_owner_unknown(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW,
                         error_response_raises_exceptions=False)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href,
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip',
                     in_progress = True,
                     suggested_identifier = "zyxwvutsrq",
                     on_behalf_of="richard") # we expressly set the wrong obo on the request rather than the connection
                     
     assert receipt.code == 403
     assert isinstance(receipt, Error_Document)
     assert receipt.error_href == "http://purl.org/net/sword/error/TargetOwnerUnknown"
 def test_35_error_checksum_mismatch(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW,
                         error_response_raises_exceptions=False)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href,
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip',
                     in_progress = True,
                     suggested_identifier = "zyxwvutsrq",
                     md5sum="123456789")
                     
     assert receipt.code == 412
     assert isinstance(receipt, Error_Document)
     assert receipt.error_href == "http://purl.org/net/sword/error/ErrorChecksumMismatch"
 def test_23_basic_add_content_to_resource_single_file(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href, 
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip')
     receipt = conn.get_deposit_receipt(receipt.location)
     
     with open(PACKAGE) as pkg:
         new_receipt = conn.add_file_to_resource(receipt.edit_media, pkg, "addition.zip", mimetype=PACKAGE_MIME)
     
     assert new_receipt.code >= 200 and new_receipt.code < 400
     assert new_receipt.location is not None
     assert new_receipt.location != receipt.edit_media
    def test_03_basic_create_resource_with_package(self):
        conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')

        assert receipt.code == 201
        assert receipt.location != None

        # these last two assertions are contingent on if we actually get a
        # receipt back from the server (which we might not legitimately get)
        assert receipt.dom is None or receipt.parsed == True
        assert receipt.dom is None or receipt.valid == True
Exemple #47
0
 def test_07_Multipart_POST_to_sss(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     e = Entry(title="Foo",
               id="asidjasidj",
               dcterms_appendix="blah blah",
               dcterms_title="foo bar")
     resp = conn.create(
         payload="Multipart payload here",
         metadata_entry=e,
         mimetype="text/plain",
         filename="readme.txt",
         packaging='http://purl.org/net/sword/package/Binary',
         workspace='Main Site',
         collection=conn.sd.workspaces[0][1][0].title,
         in_progress=True)
     assert resp.code == 201
    def test_30_advanced_add_multipart(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          on_behalf_of=SSS_OBO,
                          http_impl=http)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        e = Entry(title="Multipart deposit",
                  id="asidjasidj",
                  dcterms_abstract="abstract",
                  dcterms_identifier="http://whatever/")
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                metadata_entry=e,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')

        # ensure that we have a receipt (the server may not give us one
        # by default)
        receipt = conn.get_deposit_receipt(receipt.location)

        ne = Entry(title="Multipart deposit",
                   id="asidjasidj",
                   dcterms_identifier="http://another/",
                   dcterms_creator="Me!",
                   dcterms_rights="CC0")
        with open(PACKAGE) as pkg:
            new_receipt = conn.append(
                dr=receipt,
                metadata_entry=ne,
                payload=pkg,
                filename="addition.zip",
                mimetype=PACKAGE_MIME,
                packaging="http://purl.org/net/sword/package/SimpleZip",
                in_progress=True,
                metadata_relevant=True)

        assert new_receipt.code >= 200 and new_receipt.code < 400
Exemple #49
0
 def test_14_Invalid_Packaging_cached_receipt(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True,
                       honour_receipts=True)
     col_iri = conn.sd.workspaces[0][1][0].href  # pick the first collection
     dr = conn.create(payload="Payload is just a load of text",
                      mimetype="text/plain",
                      filename="readme.txt",
                      packaging='http://purl.org/net/sword/package/Binary',
                      col_iri=col_iri,
                      in_progress=True)
     # Now to GET that resource with invalid packaging
     try:
         content = conn.get_resource(dr.cont_iri, packaging="foofar")
         assert 1 == 0  # fail
     except PackagingFormatNotAvailable:
         # test the 'honour_receipts' flag and cached deposit
         pass
    def test_09_basic_retrieve_deposit_receipt(self):
        conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip')

        # we're going to work with the location
        assert receipt.location != None

        new_receipt = conn.get_deposit_receipt(receipt.location)

        assert new_receipt.code == 200
        assert new_receipt.parsed == True
        assert new_receipt.valid == True
    def test_36_error_bad_request(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          error_response_raises_exceptions=False)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip',
                in_progress="Invalid",  # the API seems to allow this!
                suggested_identifier="zyxwvutsrq")

        assert receipt.code == 400
        assert isinstance(receipt, Error_Document)
        assert receipt.error_href == "http://purl.org/net/sword/error/ErrorBadRequest"
Exemple #52
0
 def test_22_Create_deposit_and_delete_deposit(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     e = Entry(title="Foo",
               id="asidjasidj",
               dcterms_appendix="blah blah",
               dcterms_title="foo bar")
     deposit_receipt = conn.create(
         payload="Multipart_POST_then_update_on_EM_IRI",
         metadata_entry=e,
         mimetype="text/plain",
         filename="readme.txt",
         packaging='http://purl.org/net/sword/package/Binary',
         col_iri=conn.sd.workspaces[0][1][0].href,
         in_progress=True)
     assert deposit_receipt.edit != None
     dr = conn.delete(resource_iri=deposit_receipt.edit)
     assert dr.code == 204 or dr.code == 200
    def test_35_error_checksum_mismatch(self):
        conn = Connection(SSS_URL,
                          user_name=SSS_UN,
                          user_pass=SSS_PW,
                          error_response_raises_exceptions=False)
        conn.get_service_document()
        col = conn.sd.workspaces[0][1][0]
        with open(PACKAGE) as pkg:
            receipt = conn.create(
                col_iri=col.href,
                payload=pkg,
                mimetype=PACKAGE_MIME,
                filename="example.zip",
                packaging='http://purl.org/net/sword/package/SimpleZip',
                in_progress=True,
                suggested_identifier="zyxwvutsrq",
                md5sum="123456789")

        assert receipt.code == 412
        assert isinstance(receipt, Error_Document)
        assert receipt.error_href == "http://purl.org/net/sword/error/ErrorChecksumMismatch"
 def test_16_basic_replace_file_content(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href, metadata_entry = e)
     
     # ensure that we have a receipt (the server may not give us one
     # by default)
     receipt = conn.get_deposit_receipt(receipt.location)
     
     # now do the replace
     with open(PACKAGE) as pkg:
         new_receipt = conn.update(dr = receipt,
                         payload=pkg,
                         mimetype=PACKAGE_MIME,
                         filename="update.zip",
                         packaging='http://purl.org/net/sword/package/SimpleZip')
     
     assert new_receipt.code == 204
     assert new_receipt.dom is None
Exemple #55
0
 def test_23_Finish_in_progress_deposit(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER,
                       user_name="sword",
                       user_pass="******",
                       download_service_document=True)
     e = Entry(title="Foo",
               id="asidjasidj",
               dcterms_appendix="blah blah",
               dcterms_title="foo bar")
     deposit_receipt = conn.create(
         payload="Multipart_POST_then_update_on_EM_IRI",
         metadata_entry=e,
         mimetype="text/plain",
         filename="readme.txt",
         packaging='http://purl.org/net/sword/package/Binary',
         col_iri=conn.sd.workspaces[0][1][0].href,
         in_progress=True)
     assert deposit_receipt.edit != None
     dr = conn.complete_deposit(se_iri=deposit_receipt.se_iri)
     print "This will fail until the sss.py SWORD2 server responds properly, rather than with code 201"
     assert dr.code == 200
 def test_08_advanced_create_resource_with_entry(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     
     e = Entry(title="An entry only deposit", id="asidjasidj", 
                 dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     e.register_namespace("oxds", "http://databank.ox.ac.uk/terms/")
     e.add_field("oxds_whatever", "whatever")
     
     receipt = conn.create(col_iri = col.href,
                 metadata_entry = e,
                 in_progress = True,
                 suggested_identifier = str(uuid.uuid4()))
     
     assert receipt.code == 201
     assert receipt.location != None
     
     # these last two assertions are contingent on if we actually get a 
     # receipt back from the server (which we might not legitimately get)
     assert receipt.dom is None or receipt.parsed == True
     assert receipt.dom is None or receipt.valid == True
 def test_36_check_md5(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
     receipt = conn.create(col_iri = col.href, metadata_entry = e)
     with open(PACKAGE) as pkg:
         new_receipt = conn.update(dr = receipt,
                         payload=pkg,
                         mimetype=PACKAGE_MIME,
                         filename="update.zip",
                         packaging='http://purl.org/net/sword/package/SimpleZip',
                         md5sum="123456789") # pass in a known md5 (even though it is wrong)
     statement = conn.get_ore_sword_statement(receipt.ore_statement_iri)
     
     # need to try and extract the md5 from the dom
     count = 0
     for element in statement.dom.findall("{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description/{http://vocab.ox.ac.uk/dataset/schema#}hasMD5"):
         count += 1
         assert element.text.strip() == "123456789"
     
     assert count == 1